I am getting a SerializationException for an enum when calling from one AppDomain into another:
System.Runtime.Serialization.SerializationException:
Type is not resolved for member
‘Dummy.MyEnum,Dummy, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null’.
Sample code:
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 the exception:
getFooBarInOtherAppDomain().Test1(MyEnum.A);
When using any other serializable type it succeeds:
getFooBarInOtherAppDomain().Test2(0);
Caller, callee and enum are defined in the same assembly.
What does .Net mean with “Type is not resolved” and why is the exception thrown? Aren’t enums serializable by default?
Each AppDomain has its own probing path for assemblies, configured with the AppDomainSetup class. The app.config file for the primary AppDomain. It looks like in your case it is finding an assembly to load but a different one from the one that was used to serialize the data. The one it found is missing the enum type. Troubleshoot this with Fuslogvw.exe, it lets you see what assemblies are being resolved.