i've a strange issue 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 an argumentnullexpcetion with the message: "value cannot be null" when the generic types are the same.
if i change the docallback to this:
appDomain.DoCallBack(MyDoCallBack<string, int>); <-- OK!
that means if the generic types are different, there is no problem.
what is wrong or is this a .net bug??
UPDATE: lambda isn't 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>()); //<--ArgumentNullException
}
static void MyDoCallBack<T, T1>() {}
This is a bug in the .NET Remoting infrastructure. This is a crash in .NET internal code.
I don't have a good workaround. You could compile a non-generic wrapping function using expression trees. You would need one such lambda per set of generic type arguments.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With