.NET 4 配置中的“useLegacyV2RuntimeActivationPolicy"有什么作用? [英] What does 'useLegacyV2RuntimeActivationPolicy' do in the .NET 4 config?

查看:34
本文介绍了.NET 4 配置中的“useLegacyV2RuntimeActivationPolicy"有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在将使用 SlimDX 且因此具有非托管代码的项目转换为 .NET 4.0 时,我遇到了以下错误:

<块引用>

混合模式程序集是针对运行时的v2.0.50727"版本构建的,如果没有附加配置信息,则无法在 4.0 运行时中加载.

谷歌搜索给了我解决方案,即将其添加到应用程序配置中:

<预><代码><配置><启动 useLegacyV2RuntimeActivationPolicy="true"><supportedRuntime version="v4.0"/></启动></配置>

我的问题是,useLegacyV2RuntimeActivationPolicy 在做什么?我找不到任何关于它的文档.

解决方案

经过一段时间(和更多搜索),我找到了 此博客条目,作者:Jomo Fisher.

<块引用>

我们最近看到的一个问题是,由于支持并行运行时,.NET 4.0 改变了它绑定到旧混合模式程序集的方式.例如,这些程序集是从 C++CLI 编译的程序集.当前可用的 DirectX 程序集是混合模式.如果您看到这样的消息,则说明您遇到了问题:

混合模式程序集是针对运行时的v1.1.4322"版本构建的,如果没有附加配置信息,则无法在 4.0 运行时中加载.

[剪辑]

对于应用程序来说,好消息是您可以选择通过设置 app.config 标志来为这些程序集回退到 .NET 2.0 时代绑定,如下所示:

<supportedRuntime version="v4.0"/></启动>

所以看起来运行时加载混合模式程序集的方式已经改变.我找不到有关此更改的任何详细信息,也找不到更改的原因.但是 useLegacyV2RuntimeActivationPolicy 属性恢复为 CLR 2.0 加载.

While converting a project that used SlimDX, and therefore has unmanaged code, to .NET 4.0 I ran into the following 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.

Googling around gave me the solution, which is to add this to the applications config:

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

My question is, what is the useLegacyV2RuntimeActivationPolicy doing? I can't find any documentation about it.

解决方案

After a bit of time (and more searching), I found this blog entry by Jomo Fisher.

One of the recent problems we’ve seen is that, because of the support for side-by-side runtimes, .NET 4.0 has changed the way that it binds to older mixed-mode assemblies. These assemblies are, for example, those that are compiled from C++CLI. Currently available DirectX assemblies are mixed mode. If you see a message like this then you know you have run into the issue:

Mixed mode assembly is built against version 'v1.1.4322' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.

[Snip]

The good news for applications is that you have the option of falling back to .NET 2.0 era binding for these assemblies by setting an app.config flag like so:

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

So it looks like the way the runtime loads mixed-mode assemblies has changed. I can't find any details about this change, or why it was done. But the useLegacyV2RuntimeActivationPolicy attribute reverts back to CLR 2.0 loading.

这篇关于.NET 4 配置中的“useLegacyV2RuntimeActivationPolicy"有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆