I have a strange problem with AppDomain.DoCallBack () and generic types:
static void InvokeIsolated() { AppDomain appDomain = AppDomain.CreateDomain("testDomain"); appDomain.DoCallBack(MyDoCallBack<string, string>); <-- ArgumentNullException! } static void MyDoCallBack<T, T1>() {}
I get a nullexpcionion argument with the message: "value cannot be null" when the generic types are the same.
if I change docallback to this:
appDomain.DoCallBack(MyDoCallBack<string, int>); <-- OK!
This means that if the generic types are different from each other, there is no problem.
what is wrong or is it a .net error?
UPDATE: lambda is not a workaround if called with generic types:
static void Foo() { InvokeIsolated<string, string>(); } static void InvokeIsolated<T, T1>() { AppDomain appDomain = AppDomain.CreateDomain("testDomain"); appDomain.DoCallBack(() => MyDoCallBack<T, T1>());
source share