【发布时间】:2012-10-06 19:23:30
【问题描述】:
我正在使用 .NET 框架 4.5 在 C# 上构建应用程序,但我使用的其中一个 dll 是使用 .NET 2.0 构建的,因此我正在尝试添加混合模式汇编功能。
这是我收到的错误: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.
我试过这个http://msdn.microsoft.com/en-us/library/bbx34a2h.aspx,现在我的 app.config 看起来像这样:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup>
</configuration>
当我在 Visual Studio 中以发布模式运行应用程序时,它按预期运行,但是当我尝试在其工作环境中运行它时,它会因上述错误而崩溃。
我也尝试过 [Mixed Mode Error when building in Release Mode],但没有成功。
我还错过了什么吗?
【问题讨论】:
-
您调用应用程序的位置是否在其附近放置了 appname.exe.config 文件?当您从发布文件夹本身运行它时,它是否也直接运行?
-
它在一个单独的目录上运行,我将 appname.exe.config 文件复制到工作目录,现在它正在运行!谢谢
标签: c# .net-assembly mode mixed