简体   繁体   English

是否可以在同一进程中加载​​两个版本的.NET运行时?

[英]Is it possible to load two versions of the .NET runtime in the same process?

There are two scenarios I need to clarify: 我需要澄清两种情况:

  1. An executable compiled with .NET 3.5 needs to use a library compiled with .NET 1.1 and the library must run on the 1.1 runtime. 使用.NET 3.5编译的可执行文件需要使用使用.NET 1.1编译的库,并且库必须在1.1运行时运行。

  2. An executable compiled with .NET 1.1 needs to use a library compiled with .NET 3.5. 使用.NET 1.1编译的可执行文件需要使用使用.NET 3.5编译的库。

I cannot find a reliable source stating that it is not possible to load two versions of the .NET runtime and Microsoft's documentation is very vague on this matter. 我找不到一个可靠的来源,说明无法加载两个版本的.NET运行时,而且微软的文档在这个问题上非常模糊。

No -- you can't load the CLR into the same process twice. 否 - 您无法将CLR加载到同一进程中两次。 See the documentation for CLR Hosting 请参阅CLR Hosting的文档

As with earlier versions of the runtime, the CorBindToRuntimeEx function initializes the runtime. 与早期版本的运行时一样,CorBindToRuntimeEx函数初始化运行时。 You can choose which version of the runtime to load, but a process can host only one version . 您可以选择要加载的运行时版本,但进程只能 托管一个版本

.NET 4承诺通过In-Process Side-Side在同一进程中托管不同的CLR版本。

For case #1, is there any particular reason (say, breaking changes) which requires the library to be hosted in the 1.1 runtime? 对于情况#1,是否有任何特殊原因(例如,重大变化)需要将库托管在1.1运行时? Is it possible to expose the library via a 1.1-compiled web service, and have the executable point to the web service instead? 是否可以通过1.1编译的Web服务公开库,并将可执行文件指向Web服务? (Or some other remoting technique, to get the library in its own process?) (或者其他一些远程处理技术,让库在自己的进程中?)

For case #2, is it possible to recompile the 1.1 app under 2.0/3.5, such that it can reside in the same process? 对于情况#2,是否可以在2.0 / 3.5下重新编译1.1应用程序,以便它可以驻留在同一个进程中?

In any event, Rob Walker is right (and I upvoted) -- you simply can't host 2 versions of the runtime in the same process. 无论如何,Rob Walker是对的(我赞成) - 你根本无法在同一个进程中托管2个版本的运行时。 So you need to work around it somehow. 所以你需要以某种方式解决它。 I'd imagine that in both cases, source must be available, so recompilations and retesting should play. 我想,在这两种情况下,源都必须可用,因此应该重新编译和重新测试。

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

相关问题 一个进程是否可以加载两个同名但版本不同的dll? - Is it possible for a process to load two dll with same name but different versions? 使用Prism,两个模块是否可以引用同一装配体的不同版本? - With Prism, is it possible for two modules to reference different versions of the same assembly? 在 Asp.Net 中并行运行相同 Dll 的两个版本 - Running two versions of same Dll parallel in Asp.Net 如何从两个不同的子文件夹将两个版本的相同程序集加载到两个不同的域中? - How can I load two versions of same assemblies into two different domains from two different subfolders? .NET:加载同一DLL的两个版本 - .NET: Load two version of the same DLL 运行时的.Net Load Reference - .Net Load Reference at runtime .NET运行时如何确定两种类型是否相同? - How does the .NET runtime determine that two types are the same? 是否无法加载使用不同 NETCore 版本构建的两个 C# COM 对象? - Is it not possible to load two C# COM object built with different NETCore versions? 不同的运行时版本和新的.NET CLI - Distinct runtime versions and the new .NET CLI 两个应用程序加载相同的.NET程序集:相同的实例? - Two applications load same .NET assembly: same instance?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM