5

I have c# asmx service project that was running on framework 2 with vs 2008 Now i have updated it to framework 4 with vs 2010

when i build dll in debug mode it compiles successfully but when i build in release mode i get the following error:

Error 51 Mixed mode assembly is built against version 'v1.1.4322' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information. C:\Service\MycService\SGEN

UPDATE: Ok, I change the framework to 3.5 from project properties its build ok in release mode, but what's the problem in framework 4.0. I need it to be working in framework 4.0

Ali Hasan
  • 1,045
  • 4
  • 16
  • 43
  • In the project settings, do you see a difference in how you are building in the configuration manager or in the Build section? – Davin Tryon Feb 06 '12 at 12:07
  • You have your answer at http://stackoverflow.com/questions/4018924/mixed-mode-assembly-is-built-against-version-v1-1-4322 – Ravi Vanapalli Feb 06 '12 at 12:35
  • @Ravia The answer has a win application which has an app.Config file and set useLegacyV2RuntimeActivationPolicy, mine is web application do you mean that i have to add useLegacyV2RuntimeActivationPolicy in my webconfig – Ali Hasan Feb 06 '12 at 12:44

3 Answers3

13

I got it working By going to Project-> Right Click-> Properties-> Build->Generate Serialiazation Assembly Change Value here "Auto" to Off and build on release mode it now works

Ali Hasan
  • 1,045
  • 4
  • 16
  • 43
  • I did the same thing and it works. But do you know that reason? – SaraNa Dec 23 '15 at 00:49
  • @SaraNa I think mixed mode assembly cannot be consumed by a .NET 4.0 application by design that is why we need turn off Generate Serialiazation Assembly. – Ali Hasan Dec 26 '15 at 10:42
1

Do you have unmanaged code in your solution, or do you build against one?
We had run into such issue at work when we moved to work with VS2010 and .net 4.
What worked for us was adding App.config file to the project which contains the following:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
</configuration>
Maya
  • 11
  • 2
0

You would have to put it inside configuration tag check the link http://msdn.microsoft.com/en-us/library/bbx34a2h.aspx, which was also there in previous link answer.

Ravi Vanapalli
  • 9,805
  • 3
  • 33
  • 43