我正在尝试在单独的应用程序域上创建动态程序集,如下所示:
string webProfilesNamespace = ConfigurationManager.AppSettings["Profiles.Web.Namespace"];
AssemblyName webAName = new AssemblyName(webProfilesNamespace);
AppDomain webDomain = AppDomain.CreateDomain("WebDomain");
AssemblyBuilder webAsmBuilder = webDomain.DefineDynamicAssembly(webAName, AssemblyBuilderAccess.RunAndSave);
问题是当我调用 DefineDynamicAssebly
时,我不断收到此错误:
Type 'System.Reflection.Emit.AssemblyBuilder' in assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.
我需要做什么才能在新创建的应用程序域上定义动态程序集?
最佳答案
在新应用域中调用DefineDynamicAssembly
。也许可以使用 AppDomainCallback 来做到这一点。我忘了这个方法叫什么了。
关于c# - 在新应用程序域上创建动态程序集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31525881/