locked
Mixed mode assembly is built against version ... cannot be loaded in the 4.0 runtime without additional configuration information. RRS feed

  • Question

  • When updating my C++ applications from Visual Studio 8 to Visual Studio 10 I get the runtime error "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." What is the "additional configuration information" the error refers to and where is it entered?

     

    Monday, May 10, 2010 4:25 PM

Answers

  • Hi w5801,

    If you want to use CLR version 4 to load an assembly that was created with CLR version 1.1 or 2.0, include version 4 in the list of supported runtimes and set the useLegacyV2RuntimeActivationPolicy attribute to true. This enables the .NET Framework version 2.0 activation policy, which loads the assembly using the highest supported CLR version.

     

    Try to add following codes to your application configuration file.

     

    <?xml version="1.0" encoding="utf-8" ?>

    <configuration>

      <startup useLegacyV2RuntimeActivationPolicy="true">

        <supportedRuntime version="v4.0"/>

      </startup>

    </configuration>

     

    The .NET Framework version 2.0 activation policy is to load all assemblies by using the latest supported version of the CLR. Starting with the .NET Framework 4, the default activation policy is to cap this "roll-forward" behavior at the latest CLR version before version 4. In most cases, the latest CLR version before version 4 is CLR version 2.0, which is used in all .NET Framework versions from 2.0 through 3.5 SP1. This default policy loads most assemblies by using the CLR version they were compiled with, providing greater compatibility.

     

    Thus, if the list of supported runtimes includes CLR version 1.1, CLR version 2.0, and CLR version 4, an assembly that was compiled with CLR version 1.1 or CLR version 2.0 is loaded by using CLR version 2.0 by default. An assembly that is compiled with CLR version 4 is loaded by using CLR version 4.

     

    Cheers

    Yi Feng Li

     

     

     


    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.
    • Proposed as answer by Yi Feng Li Monday, May 17, 2010 2:13 AM
    • Marked as answer by Yi Feng Li Tuesday, May 18, 2010 3:21 AM
    Wednesday, May 12, 2010 8:12 AM

All replies

  • Well, I would actually question why, after updating from Visual Studio 2005 to Visual Studio 2010 it is trying to run an assembly against Version 1.1 of the framework. The compiler which comes with 2005 targets .NET version 2.0 not 1.1. Visual Studio 2010 targets .NET 4, so after an upgrade it should be targetting 4, and any files built with Visual Studio should target 4.

    So this makes me wonder, are you depending on any third party mixed mode assemblies?


    Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.
    Visit my (not very good) blog at
    http://c2kblog.blogspot.com/
    Monday, May 10, 2010 4:32 PM
  • Hi w5801,

    If you want to use CLR version 4 to load an assembly that was created with CLR version 1.1 or 2.0, include version 4 in the list of supported runtimes and set the useLegacyV2RuntimeActivationPolicy attribute to true. This enables the .NET Framework version 2.0 activation policy, which loads the assembly using the highest supported CLR version.

     

    Try to add following codes to your application configuration file.

     

    <?xml version="1.0" encoding="utf-8" ?>

    <configuration>

      <startup useLegacyV2RuntimeActivationPolicy="true">

        <supportedRuntime version="v4.0"/>

      </startup>

    </configuration>

     

    The .NET Framework version 2.0 activation policy is to load all assemblies by using the latest supported version of the CLR. Starting with the .NET Framework 4, the default activation policy is to cap this "roll-forward" behavior at the latest CLR version before version 4. In most cases, the latest CLR version before version 4 is CLR version 2.0, which is used in all .NET Framework versions from 2.0 through 3.5 SP1. This default policy loads most assemblies by using the CLR version they were compiled with, providing greater compatibility.

     

    Thus, if the list of supported runtimes includes CLR version 1.1, CLR version 2.0, and CLR version 4, an assembly that was compiled with CLR version 1.1 or CLR version 2.0 is loaded by using CLR version 2.0 by default. An assembly that is compiled with CLR version 4 is loaded by using CLR version 4.

     

    Cheers

    Yi Feng Li

     

     

     


    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.
    • Proposed as answer by Yi Feng Li Monday, May 17, 2010 2:13 AM
    • Marked as answer by Yi Feng Li Tuesday, May 18, 2010 3:21 AM
    Wednesday, May 12, 2010 8:12 AM
  • This is very helpful across all languages, thank you!

    I'm posting mainly to add this to my threads so I don't loose it.  :)


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
    Wednesday, November 24, 2010 8:58 PM
  • thank you very much!!!
    Tuesday, December 7, 2010 3:31 PM
  • I have seen this solution everywhere on the internet, but it doesn't seem to work for me.  I'm trying to get started in DirectX programming, so I downloaded a sample project .  I made the edit you show above to the Application.myapp file, but I still get the error.

    Any help would be great.

    Wednesday, March 9, 2011 2:12 PM
  • gregsdennis,

    The myapp file is not the correct file to modify. If you do not have an app.config file, you can add one by right-clicking your project in the solution explorer, and then going to add --> new item. Then, under the "General" category, select "Application Configuration File". An app.config file should appear in your solution explorer and you can modify that file according to what Yi Feng Li has posted.

     

    Monday, April 25, 2011 5:11 AM
  • I agree to it, it do resolve issue. When its case of startup project it do have App.config. Where we can add extra properties set at start of this thread, which resolves the issue.

    But i am having solution with number of projects which do have same error on all workstations. This I am not able to resolve , I also tried adding App.config and setting this one, Still Error continues, and do not respecting properties here. One more thing to clear is, there are some binaries in those projects which are developed in framework 2.0 and participating as dll reference in that project.How we can deal with this?

    I would mention here the workaround for this-

    Project-> Right Click-> Properties-> Build->Generate Serialiazation Assembly 

    Change Value here "Auto" to Off

    Is there any effect of this on application if checked in across solution?

    Help is much appreciated on this.

    Thanks

    Sandy

     

    Friday, August 26, 2011 10:07 AM
  • Its dont work :> i do it Off but it say the same error
    Tuesday, September 6, 2011 10:08 PM
  • I have tried making this change in the app.config, even then I keep running in to the error

    Error    247    Mixed mode assembly is built against version 'v1.0.3705' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.   

    Also, I need to generate the serialize assembly for this code so I have kept the "Generate serialization assembly: On".

    Target Framework for the project is .NET 4.0

    Any inputs on this?

    Tuesday, February 14, 2012 6:46 PM
  • Thanks Yi Feng Li, this help me a lot.  
    Thursday, May 3, 2012 3:06 PM
  • gregsdennis,

    The myapp file is not the correct file to modify. If you do not have an app.config file, you can add one by right-clicking your project in the solution explorer, and then going to add --> new item. Then, under the "General" category, select "Application Configuration File". An app.config file should appear in your solution explorer and you can modify that file according to what Yi Feng Li has posted.

     

    Thanks ;)
    Thursday, May 3, 2012 3:07 PM
  • Thanks! A great answer!

    If you want something you've never had, you need to do something you've never done.

    Friday, August 31, 2012 8:36 AM
  • I have this error too. But you can do by this way. Right click on project-> add exit items-> choose App.Config anh OK. In this App.Config, edit the code like above
    Thursday, April 25, 2013 3:45 AM
  • I had this error too when i initialised object of DirectX. I have done edit App.Config but still get error. I did like below: Right click project-> Add Exit Items -> choose the App.config in my project folder and OK. Then edit code like above. That run ok
    Thursday, April 25, 2013 3:55 AM
  • I had this error too when i initialised object of DirectX. I have done edit App.Config but still get error. I did like below: Right click project-> Add Exit Items -> choose the App.config in my project folder and OK. Then edit code like above. That run ok

    • Proposed as answer by Duke Yang Wednesday, July 10, 2013 7:05 AM
    Thursday, April 25, 2013 3:55 AM
  • Thanks DzungLM

    I fixed my problem with your instructions. I am so happy.

    I strongly recommand this solution to people which have still same problem even though you added useLegacyV2RuntimeActivationPolicy="true" in app.config file.

    Wednesday, July 10, 2013 7:08 AM