Mixed mode assembly is built against 'v2.0.50727' error

29,189

Solution 1

http://support.microsoft.com/kb/2572158

Add the verbiage useLegacyV2RuntimeActivationPolicy="true" below either to either of the following locations:

  1. sgen.exe.config file located at the following location: ..\Program Files\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\
  2. The applications' app.config file

<startup useLegacyV2RuntimeActivationPolicy="true">

            <supportedRuntime version="v4.0" />

</startup>    

Solution 2

If you're running in 64-bit, you may have to add it to the Visual Studio test engine config:

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.executionengine.exe.config

Add the startup node like so:

<startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
    <requiredRuntime version="v4.0.20506" />
</startup>
Share:
29,189
ganders
Author by

ganders

I'm a software developer in Des Moines, IA. I love what I do, but wish I had more time to do it. Those darn kids get in the way...

Updated on July 19, 2022

Comments

  • ganders
    ganders almost 2 years

    First of all, I've found the other posts on StackOverflow here, but it did not resolve my error.

    I have 3 different environments/domains with a build server in each location. My Dev and UAT environments build just fine, but the production version does not work.

    I'm getting the error

    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

    I've added this tag to my app.config file (which was the suggested fix in the link I have above)

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

    What else could be different between my build servers/environments/domains that would be causing this issue?

    In response to Allen's question, I believe this is what you're asking:

    <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup>
        <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
        <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
        <ProductVersion>8.0.30703</ProductVersion>
        <SchemaVersion>2.0</SchemaVersion>
        <ProjectGuid>{D3D87C05-2811-489B-9F0D-7676B6485AA0}</ProjectGuid>
        <OutputType>Exe</OutputType>
        <AppDesignerFolder>Properties</AppDesignerFolder>
        <RootNamespace>MVST.Batch.CorrespondenceConversion</RootNamespace>
        <AssemblyName>MVST.Batch.CorrespondenceConversion</AssemblyName>
        <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
        <FileAlignment>512</FileAlignment>
      </PropertyGroup>
    

    I have over 100 other projects that are setup the exact same way and those build ok.

  • ganders
    ganders over 11 years
    Now that I've implemented the above in my code to get it to build, it now fails when I try and run the job. If I comment out that whole section, then the job will run ok. So how do I meet in the middle? I need that section to get the project to build, but I need to comment it out in order for the program to run...
  • pennyrave
    pennyrave about 9 years
    I added the above attribute to my app.config and everything ran fine.
  • Taegost
    Taegost almost 8 years
    I just want to point out that the needed part is: useLegacyV2RuntimeActivationPolicy="true"