在 .NET 4.0 进程中创建 .NET 2.0 AppDomain [英] Create .NET 2.0 AppDomain in .NET 4.0 process

查看:20
本文介绍了在 .NET 4.0 进程中创建 .NET 2.0 AppDomain的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从我的 .NET 4.0 进程中动态创建一个与 .NET 2.0 兼容的程序集.目前它是通过这个实现的:

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

但不幸的是,所有生成的 dll 都是 .NET 4.0(从我的 4.0 进程继承而来),它不适用于我的其他 .NET 2.0 进程.

知道 2 个不同的 CLR 版本的 AppDomains 如何在同一进程中共存吗?

解决方案

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

Paul Zhou 解释说,可以在同一个 Windows 进程中托管多个 CLR,并提供以下链接以获取更多详细信息:

然而,链接看起来并不完全是一项微不足道的任务......

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(...);

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.

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

解决方案

Have a look at this question: http://social.msdn.microsoft.com/Forums/en/clr/thread/1bfd7f40-fd57-4c9f-803f-aa4b19214af9.

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:

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

这篇关于在 .NET 4.0 进程中创建 .NET 2.0 AppDomain的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆