Mixed mode assembly is built against 'v2.0.50727' error
Asked Answered
A

4

9

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.

Asbestos answered 11/2, 2013 at 15:17 Comment(7)
Is .Net 4.0 installed on production ?Fuliginous
Yes, I show in C:\Windows\Microsoft.NET\Framework folder as well as the Framework64 folder both have v4.0.30319Asbestos
which version of the platform toolset does your mixed mode assembly require and is that present on the prod server?Morello
allen I updated my question with a response to your question, If I understood it correctly...Asbestos
allen where do I check on the prod server to see if that platform toolset exists?Asbestos
Wait are you saying it doesn't build on the production machine or run ? Your config shows .Net version 3.5Fuliginous
Not sure if people get alerts when I reply to my own answer, so I'll post here. After I implemented by fix below to target CLR version 2.0, it will build the project. But when I try and run the project it fails. I have to completely comment out that section in order for the job to run. How do I meet in the middle here? Get it to build AND get it to run?Asbestos
T
17

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>    

Thracophrygian answered 4/10, 2013 at 8:31 Comment(2)
I added the above attribute to my app.config and everything ran fine.Camelot
I just want to point out that the needed part is: useLegacyV2RuntimeActivationPolicy="true"Gazette
F
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>
Freedman answered 24/3, 2014 at 20:19 Comment(0)
A
0

Here's the fix that worked...still not sure why my project needed to be 2.0 whereas others (in the link in my question) needed to be 4.0.

  <startup>
    <supportedRuntime version="v2.0.50727"/>
  </startup>
Asbestos answered 11/2, 2013 at 18:37 Comment(1)
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...Asbestos
S
0

In the case of unit tests, should you be using Resharper for your unit tests, then you already know none of the other answers have worked for you.

Resharper launches the ResharperTestRunner (either 32 or 64 bits) in order to execute your unit tests. This file is located (at least in my system) under C:\Users[user]\AppData\Local\JetBrains\Installations\ResharperPlatform[version]. The configuration of this file should be at the same location and should have the same name, but with a .config suffix. In my system, it wasn't there. So, I created it and added this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <!-- 4.0 RTM -->
    <supportedRuntime version="v4.0.30319"/>

    <!-- 2.0 RTM -->
    <supportedRuntime version="v2.0.50727"/>
  </startup>
</configuration>

Then, my tests started to work. Hope this helps.

Sip answered 16/1, 2019 at 17:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.