What does 'useLegacyV2RuntimeActivationPolicy' do in the .NET 4 config?

前端 未结 2 1423
别跟我提以往
别跟我提以往 2020-11-22 17:06

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 buil

2条回答
  •  执笔经年
    2020-11-22 17:49

    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:

    
      
    
    

    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.

提交回复
热议问题