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

前端 未结 2 1422
别跟我提以往
别跟我提以往 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 18:03

    Here's an explanation I wrote recently to help with the void of information on this attribute. http://www.marklio.com/marklio/PermaLink,guid,ecc34c3c-be44-4422-86b7-900900e451f9.aspx (Internet Archive Wayback Machine link)

    To quote the most relevant bits:

    [Installing .NET] v4 is “non-impactful”. It should not change the behavior of existing components when installed.

    The useLegacyV2RuntimeActivationPolicy attribute basically lets you say, “I have some dependencies on the legacy shim APIs. Please make them work the way they used to with respect to the chosen runtime.”

    Why don’t we make this the default behavior? You might argue that this behavior is more compatible, and makes porting code from previous versions much easier. If you’ll recall, this can’t be the default behavior because it would make installation of v4 impactful, which can break existing apps installed on your machine.

    The full post explains this in more detail. At RTM, the MSDN docs on this should be better.

提交回复
热议问题