Pregunta

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.

¿Fue útil?

Solución

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>    

Otros consejos

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>

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>

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top