混合模式组装是针对运行时版本的v2.0.50727进行构建的。

时间:2022-09-01 19:03:22

I'm getting the following 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.

混合模式组装构建版本的v2.0.50727′4.0运行时,不能装载在运行时没有额外的配置信息。

as I was trying to export crystal report from my WPF program...

当我试图从我的WPF项目中导出crystal report时…

I have added the following in the app.config already...

我已经在app.config中添加了以下内容…

<startup useLegacyV2RuntimeActivationPolicy="true">
  <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<runtime>
  <NetFx40_LegacySecurityPolicy enabled="true"/>
</runtime>

Any experts can help????

任何专家可以帮忙吗? ? ? ?

Reference I found: http://www.davidmoore.info/2010/12/17/running-net-2-runtime-applications-under-the-net-4-runtime

参考我找到:http://www.davidmoore.info/2010/12/17/running-net-2-runtime-applications-under-the-net-4-runtime

6 个解决方案

#1


211  

Try to use this exact startup tag in your app.config under configuration node

尝试在配置节点下的app.config中使用这个启动标记。

<startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
    <requiredRuntime version="v4.0.20506" />
  </startup>

#2


66  

The exception clearly identifies some .NET 2.0.50727 component was included in .NET 4.0. In App.config file use this:

这个异常清楚地标识了。net 4.0中包含的。net 2.0.50727组件。在App.config文件中使用这个:

<startup useLegacyV2RuntimeActivationPolicy="true" /> 

It solved my problem

它解决了我的问题

#3


4  

I actually had this identical issue with the inverse solution. I had upgraded a .NET project to .NET 4.0 and then reverted back to .NET 3.5. The app.config in my project continued to have the following which was causing the above error in question:

实际上,我有一个与逆解相同的问题。我将. net项目升级到。net 4.0,然后返回。net 3.5。在我的项目中,app.config继续有如下所示的错误:

<startup>
  <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>

The solution to solve the error for this was to revert it back to the proper 2.0 reference as follows:

解决此错误的解决方案是将其还原为适当的2.0引用,如下所示:

<startup>
  <supportedRuntime version="v2.0.50727"/>
</startup>

So if a downgrade is producing the above error, you might need to back up the .NET Framework supported version.

因此,如果降级产生上述错误,您可能需要备份. net框架支持的版本。

#4


2  

Please add attribute useLegacyV2RuntimeActivationPolicy="true" in your applications app.config file.

请在应用程序app.config文件中添加属性useLegacyV2RuntimeActivationPolicy="true"。

Old Value

旧值

  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1"/>
  </startup>

New Value

新值

  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1"/>
  </startup>

It will solve your problem.

这会解决你的问题。

#5


1  

Try to use another config file (not the one from your project) and RESTART Visual Studio:

尝试使用另一个配置文件(不是您的项目中的一个)并重新启动Visual Studio:

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

C:\Program Files (x86)\Microsoft Visual Studio IDE 11.0 \ Common7 \ \ CommonExtensions \ \ TestWindow \ vstest.executionengine.x86.exe微软。配置(32位)

or

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

C:\Program Files (x86)\Microsoft Visual Studio IDE 11.0 \ Common7 \ \ CommonExtensions \ \ TestWindow \ vstest.executionengine.exe微软。配置(64位)

#6


1  

For me this was thrown when running unit tests under MSTest (VS2015). Had to add

对我来说,这是在MSTest (VS2015)下运行单元测试时抛出的。必须添加

<startup useLegacyV2RuntimeActivationPolicy="true">
</startup>

in

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\TE.ProcessHost.Managed.exe.config

C:\Program Files (x86)\Microsoft Visual Studio IDE 14.0 \ Common7 \ \ CommonExtensions \ \ TestWindow \ TE.ProcessHost.Managed.exe.config微软

Mixed-Mode Assembly MSTest Failing in VS2015

在VS2015中,混合模式组装最失败。

#1


211  

Try to use this exact startup tag in your app.config under configuration node

尝试在配置节点下的app.config中使用这个启动标记。

<startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
    <requiredRuntime version="v4.0.20506" />
  </startup>

#2


66  

The exception clearly identifies some .NET 2.0.50727 component was included in .NET 4.0. In App.config file use this:

这个异常清楚地标识了。net 4.0中包含的。net 2.0.50727组件。在App.config文件中使用这个:

<startup useLegacyV2RuntimeActivationPolicy="true" /> 

It solved my problem

它解决了我的问题

#3


4  

I actually had this identical issue with the inverse solution. I had upgraded a .NET project to .NET 4.0 and then reverted back to .NET 3.5. The app.config in my project continued to have the following which was causing the above error in question:

实际上,我有一个与逆解相同的问题。我将. net项目升级到。net 4.0,然后返回。net 3.5。在我的项目中,app.config继续有如下所示的错误:

<startup>
  <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>

The solution to solve the error for this was to revert it back to the proper 2.0 reference as follows:

解决此错误的解决方案是将其还原为适当的2.0引用,如下所示:

<startup>
  <supportedRuntime version="v2.0.50727"/>
</startup>

So if a downgrade is producing the above error, you might need to back up the .NET Framework supported version.

因此,如果降级产生上述错误,您可能需要备份. net框架支持的版本。

#4


2  

Please add attribute useLegacyV2RuntimeActivationPolicy="true" in your applications app.config file.

请在应用程序app.config文件中添加属性useLegacyV2RuntimeActivationPolicy="true"。

Old Value

旧值

  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1"/>
  </startup>

New Value

新值

  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1"/>
  </startup>

It will solve your problem.

这会解决你的问题。

#5


1  

Try to use another config file (not the one from your project) and RESTART Visual Studio:

尝试使用另一个配置文件(不是您的项目中的一个)并重新启动Visual Studio:

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

C:\Program Files (x86)\Microsoft Visual Studio IDE 11.0 \ Common7 \ \ CommonExtensions \ \ TestWindow \ vstest.executionengine.x86.exe微软。配置(32位)

or

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

C:\Program Files (x86)\Microsoft Visual Studio IDE 11.0 \ Common7 \ \ CommonExtensions \ \ TestWindow \ vstest.executionengine.exe微软。配置(64位)

#6


1  

For me this was thrown when running unit tests under MSTest (VS2015). Had to add

对我来说,这是在MSTest (VS2015)下运行单元测试时抛出的。必须添加

<startup useLegacyV2RuntimeActivationPolicy="true">
</startup>

in

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\TE.ProcessHost.Managed.exe.config

C:\Program Files (x86)\Microsoft Visual Studio IDE 14.0 \ Common7 \ \ CommonExtensions \ \ TestWindow \ TE.ProcessHost.Managed.exe.config微软

Mixed-Mode Assembly MSTest Failing in VS2015

在VS2015中,混合模式组装最失败。