创建.NET 2.0的AppDomain在.NET 4.0中的过程

创建.NET 2.0的AppDomain在.NET 4.0中的过程

问题描述:

我需要动态地从我的.NET 4.0的过程创建.NET 2.0兼容的组件。目前,它实现了这一点:

I need to dynamically create a .NET 2.0 compatible assembly from within my .NET 4.0 process. Currently it is achieved with this:

AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly(...)
ModuleBuilder  mb = assemblyBuilder.DefineDynamicModule(...);

但unfortuntely的生产的所有DLL是.NET 4.0(从我的4.0进程继承)不与我的其他.NET 2.0流程工作。

But unfortuntely all dll's produced are .NET 4.0 (inherited from my 4.0 process) which doesn't work with my other .NET 2.0 processes.

不知道如何2个不同的CLR版本的应用程序域可以共存于同一进程?

Any idea how 2 different CLR versioned AppDomains can co-exist in the same process?

有一个在这个问题:http://social.msdn.microsoft.com/Forums/en/clr/thread/1bfd7f40-fd57-4c9f-803f-aa4b19214af9.

保周解释说,这是可能的主机在同一个Windows进程多的CLR,并提供了更详细的信息,下面的链接:

Paul Zhou explains, that it is possible to host multiple CLRs in the same Windows process and provides the following links with more detailed information:

  • CLR Hosting APIs
  • Creating a host application for the .NET Common Language Runtime
  • Host CLR

不过,链接看起来像这样不正是一件容易的事情......

However, the links look like this is not exactly a trivial task...