c# - Visual Studio 添加 DLL 作为引用错误

标签 c# visual-studio

我正在向项目添加库,但收到以下错误:

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.

我不太确定我必须调整什么才能让它运行。有人知道应该进行哪些更改吗?

谢谢

下午

最佳答案

正如 Marc 所说,理想情况下您应该在 .NET 4 中重建,使您的项目面向 .NET 3.5 或更低版本。为 v2 CLR 构建的混合模式程序集使用“旧版”运行时激活技术,该技术与 v4 CLR 在同一进程中运行多个 CLR 的能力不能很好地配合。

或者,您可以将此信息添加到您的 app.config 中:

<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0"/>
  </startup>
</configuration>

参见this question , this documentation还有这个blog post了解详情。

关于c# - Visual Studio 添加 DLL 作为引用错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4311274/

相关文章:

c# - 如何更改字符串值比较

c# - Visual Studio 2013 - 窗体 "Live"预览

c# - 速记不为空 C#

C - 防止在 block 作用域中使用相同的变量名

c++ - 如何清除 (char*) 中的缓冲区?

c# - Datagridview 中的文本框示例

c# - 无法在 Visual Studio (Mac) 上使用 .NET Core 3.1 创建 Web 应用

c# - 阻止弹出式 Visual Studio

c# - Entity Framework 、SQLite 和延迟加载

在 C 中将字符串切成 2 个字符字符串的一部分,然后转换为十六进制格式(char * 到 unsigned char)