none
Having trouble loading a web service in Visual studio 2010 that uses a mixed assemnly RRS feed

  • Question

  • We have a web service that depends on a mixed assembly. After porting to VS2010, we are getting this exception :

    "Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information"

    Browsing through the internet, people have suggested adding the following to app.config and web.config files

      <startup useLegacyV2RuntimeActivationPolicy="true">
                <supportedRuntime version="v4.0" />  
      </startup>

    It doesn't even build for me with these options in the config files. I tried adding the startup optiions to devenv.exe.config and also to webdev.webserver40.exe.config too. No Luck..

     

    Any help is appreciated. Thanks

    Thursday, May 6, 2010 11:16 AM

Answers

  • This setting is not for building, it is for execution. It is not guaranteed to work 100%, otherwise this switch wouldn't be needed. The point is that older mixed mode assemblies may have serious issues on new .NET 4 (I don't know the details why - they are likely related to in-proc SxS feature). Forcing people to add this switch into config file to make it run is making them recognize "I am fully aware that this might not work".

    If you want to rebuild your 2.0/3.0/3.5 app on .NET 4 (using VS 2010), then you will have to resolve all build errors first. Note that new build errors are caused by compilers - as they improve they can discover more issues, become more strict or just fix bugs in them. There is no magic upgrade of your projects to build correctly on next version of compilers, that's manual process.

    -Karel

    Thursday, May 6, 2010 4:51 PM
    Moderator
  • SilverLight 4.0 has nothing to do with config files and desktop .NET Framework 4.0 version. Those 2 are different and independent products (like Office 2003 and Windows Server 2003 are different products which just happen to have the same version).
    Please read VS/web development documentation how to use SilverLight 4.0 in it. For web development issues please use ASP.NET forums http://forums.asp.net for SilverLight development issues please use http://forums.silverlight.net.

    Also it would be very helpful to describe your problem in step-by-step instructions (start with fresh opened VS).

    -Karel

    • Marked as answer by eryang Friday, May 21, 2010 7:36 AM
    Monday, May 10, 2010 3:59 PM
    Moderator

All replies

  • This setting is not for building, it is for execution. It is not guaranteed to work 100%, otherwise this switch wouldn't be needed. The point is that older mixed mode assemblies may have serious issues on new .NET 4 (I don't know the details why - they are likely related to in-proc SxS feature). Forcing people to add this switch into config file to make it run is making them recognize "I am fully aware that this might not work".

    If you want to rebuild your 2.0/3.0/3.5 app on .NET 4 (using VS 2010), then you will have to resolve all build errors first. Note that new build errors are caused by compilers - as they improve they can discover more issues, become more strict or just fix bugs in them. There is no magic upgrade of your projects to build correctly on next version of compilers, that's manual process.

    -Karel

    Thursday, May 6, 2010 4:51 PM
    Moderator
  • Hi sunvenu,

    How about the issue status now? please feel free to let us know if you have any concern.


    Sincerely,
    Eric
    MSDN Subscriber Support in Forum
    If you have any feedback of our support, please contact msdnmg@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, May 10, 2010 2:01 AM
  • Hello The problem seems to be the Cassini process that gets started by visual studio. we have the target platform for all the projects set for 2.0. And I aldo see webserver20.exe starting up when I start the website in the debugger. bit not sure which process is still trying to load 4.0 runtime. The only reason that we were attempting this port was to go to silverlight 4.0. We have finally decided to stay with bs 2008 for a few months as we are getting very close to the release date. Thanks
    Monday, May 10, 2010 12:29 PM
  • SilverLight 4.0 has nothing to do with config files and desktop .NET Framework 4.0 version. Those 2 are different and independent products (like Office 2003 and Windows Server 2003 are different products which just happen to have the same version).
    Please read VS/web development documentation how to use SilverLight 4.0 in it. For web development issues please use ASP.NET forums http://forums.asp.net for SilverLight development issues please use http://forums.silverlight.net.

    Also it would be very helpful to describe your problem in step-by-step instructions (start with fresh opened VS).

    -Karel

    • Marked as answer by eryang Friday, May 21, 2010 7:36 AM
    Monday, May 10, 2010 3:59 PM
    Moderator
  • Hello Karel,

     

    We moved VS2010 for all our solutions  now. But we still are running into this issue with Cassini loading the mixed assemblies. We have converted all our projects and solutions to work with VS2010 but we kept the .NET run time still to be 2.0 for other reasons. Is there any known issues with Cassini not loading the mixed mode assemblies properly?

    When I start the debugger, I see the WebDev.WebServer20.Exe spin up indicating that the only 2.0 Run time is expected. But the error still shows up as soon as there is a call to load the mixed mode assembly on the backend.

    Thursday, January 20, 2011 7:38 PM
  • Find out which process loads .NET 4.0 and tries to load your 2.0 mixed mode assembly - Process Monitor will be handy for that.

    BTW: I am not familiar with Cassini, so I do not know what is expected from it when you target .NET 2.0. When you confirm that the supposedly 2.0 Cassini process is loading CLR 4.0, I can hopefully direct you to the right forum.

    -Karel

    Thursday, January 20, 2011 8:12 PM
    Moderator
  • Karel,

    Process looks like, it is WcfSvcHost.exe that is trying to load this mixed mode assembly.

    Thanks

     

    Thursday, January 20, 2011 9:58 PM
  • Does the process load also .NET 4.0 (check %WINDIR%\Microsoft.NET\Framework\v4.0.30319\clr.dll or %WINDIR%\Microsoft.NET\Framework.v2.0.50727\mscorwks.dll)? If it is clr.dll (4.0), then WCF forums should be a good start for your question.

    -Karel

    Thursday, January 20, 2011 11:28 PM
    Moderator
  • Yes. Wcfsvchost.exe is loading .NET 4.0
    Friday, January 21, 2011 3:22 PM
  • Karel,

     

    I found a workaround for my problem. I have updated C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\WcfSvcHost.exe.config to include the following  in the configuration section

      <startup useLegacyV2RuntimeActivationPolicy="true"> 

                <supportedRuntime version="v4.0" />    

      </startup>

     

    That did solve the problem. I hope there was a better workaround than this. But for now, I guess I have to go with this.

    Thanks

     

    Friday, January 21, 2011 3:44 PM
  • Please try to ask on WCF forum as well (or file a bug via Microsoft Connect). They might be able to give you better workaround, or point you to a fix.

    -Karel

    Friday, January 21, 2011 4:37 PM
    Moderator