Using a new AppDomain inside a method that is called as a WCF service gives the following exception:
"Type 'System.Reflection.Emit.AssemblyBuilder' in assembly 'mscorlib, Version=188.8.131.52, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable."
Which is triggered by the following code:
public void DoWork()
var appDomain = AppDomain.CreateDomain("Test");
var asmBuilder = appDomain.DefineDynamicAssembly(new AssemblyName("Test"), AssemblyBuilderAccess.Run);
I tried on the following environments:
- .NET 4.0: Client/Full
- .NET 4.5: Client/Full
- Hosted on ServiceHost, IIS or Azure
All give the exact same exception.