【问题标题】:C# Mixed mode assembly release mode errorC#混合模式程序集发布模式错误
【发布时间】: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


【解决方案1】:

按照@Amitd 的建议,我将 [appname].exe.config 文件复制到了工作目录,现在应用程序按预期运行!

【讨论】:

  • 我会,但我必须等待 2 天才能这样做。
猜你喜欢
  • 2012-12-28
  • 1970-01-01
  • 1970-01-01
  • 2012-02-27
  • 1970-01-01
  • 2015-06-20
  • 2013-01-26
  • 2015-06-09
  • 2011-03-11
相关资源
最近更新 更多