Strange SerializationException for Enum in AppDomain

I get a SerializationException to enumerate when called from one AppDomain to another:

System.Runtime.Serialization.SerializationException: Type not allowed for member 'Dummy.MyEnum, Dummy, Version = 1.0.0.0, Culture = Neutral, PublicKeyToken = null'.

Code example:

public enum MyEnum
{    
  A = 0,    
  B = 1,    
  C = 2,
}

public class FooBar : MarshalByRefObject
{
  public void Test1(MyEnum dummy)
  {
  }

  public void Test2(object dummy)
  {
  }
}

This call will throw an exception:

 getFooBarInOtherAppDomain().Test1(MyEnum.A);

When using any other serializable type, it succeeds:

 getFooBarInOtherAppDomain().Test2(0);

The caller, callee, and enumerator are defined in the same assembly.

What does .Net mean that "Type is not allowed" and why is an exception thrown? Are serializable by default allowed?

+3
source share
1 answer

AppDomain , AppDomainSetup. app.config AppDomain. , , , . , , . Fuslogvw.exe, , .

+1

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


All Articles