AppDomain.DoCallBack () with the output of several common types

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>()); //<--ArgumentNullException } static void MyDoCallBack<T, T1>() {} 
+5
source share
1 answer

This is a bug in the .NET Remoting framework. This is a crash inside the .NET .NET code.

I have no good workaround. You can compile a non-general wrapping function using expression trees. You will need one such lambda for a set of arguments of a general type.

+1
source

Source: https://habr.com/ru/post/1213413/


All Articles