简体   繁体   English

在 .net 4.0 应用程序中引用 .net 2.0 程序集

[英]Referencing .net 2.0 assemblies in .net 4.0 application

I have a .net 4.0 project in which I'd like to reference .net 2.0 assemblies.我有一个 .net 4.0 项目,我想在其中引用 .net 2.0 程序集。 As I understood from this article, .net 2.0 assemblies will be loaded in 4.0 run time and backward compatibility is not assured.正如我从理解文章,.NET 2.0组件将在4.0运行时间被加载和向后兼容性得不到保证。 Is there a way to force process side by side for this case and to load 2.0 runtime?有没有办法在这种情况下并排强制处理并加载 2.0 运行时?

In process side-by-side versioning is only supported for code that runs independently without having to share data.进程并行版本控制仅支持独立运行而无需共享数据的代码。 In particular for native code that loads the CLR to execute managed code.特别是对于加载 CLR 以执行托管代码的本机代码。 It is a solution for the CLR versioning problem, once an unmanaged program like Explorer loads the CLR, say to support a shell extension written in .NET then the CLR version is selected by whatever version that extension asked for.它是 CLR 版本控制问题的解决方案,一旦像 Explorer 这样的非托管程序加载 CLR,比如说支持用 .NET 编写的 shell 扩展,那么 CLR 版本就会由该扩展要求的任何版本选择。 Which works poorly if another extension then needs a later version of the CLR.如果另一个扩展需要更高版本的 CLR,则效果不佳。 .NET 4's side-by-side versioning feature solves that, each extension gets its own CLR. .NET 4 的并行版本控制功能解决了这个问题,每个扩展都有自己的 CLR。 No sharing of data is required, these extensions don't know about each other.不需要共享数据,这些扩展彼此不知道。

Clearly this isn't a solution for what you are trying to do.显然,这不是您想要做的事情的解决方案。 Microsoft made a lot of effort to make .NET 4.0 as compatible as possible with previous .NET releases and loading .NET 2.0 assemblies is certainly well supported. Microsoft 付出了很多努力使 .NET 4.0 尽可能与以前的 .NET 版本兼容,并且加载 .NET 2.0 程序集当然得到很好的支持。 Up to a point, they did use the opportunity to fix several old bugs whose fixes could be breaking to old code.在某种程度上,他们确实利用这个机会修复了几个可能会破坏旧代码的旧错误。 Technically it is possible that your 2.0 code relied on the behavior of such a bug, it is however not very likely.从技术上讲,您的 2.0 代码可能依赖于此类错误的行为,但可能性不大。 You just need to re-test your code.你只需要重新测试你的代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM