All,
I'm getting an unexplained error when calling CreateInstanceAndUnwrap on a new appdomain I have created. The full error text is:
Type 'System.Net.Http.HttpRequestMessage' in assembly 'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable.
The child appdomain is created within a web API app, and the type I'm attempting to create a proxy for derives from MarshalByRefObject.
The assembly where this type is defined has no reference to System.Net.Http or System.Web - so I'm not clear why HttpRequestMessage serializability has any bearing.
My guess is it's trying to copy some contextual data over from the parent AppDomain to the child one, but perhaps someone here could shed some light on what's going on?
Here's the relevant code:
var appDomain = AppDomain.CreateDomain("AName", null, AppDomain.CurrentDomain.SetupInformation);
SomeClient client = appDomain.CreateInstanceAndUnwrap(typeof(SomeClient).Assembly.FullName, typeof(SomeClient).FullName) as SomeClient;
The "SomeClient" type and its parent assembly don't have any web/system.net.http references.