Create .NET 2.0 AppDomain in .NET 4.0 process

风流意气都作罢 提交于 2019-12-10 11:07:36

问题


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?


回答1:


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:

  • 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...



来源:https://stackoverflow.com/questions/6689318/create-net-2-0-appdomain-in-net-4-0-process

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!