I have an enum type in my first assembly, like below:
public enum MyEnum
{
ONE,
TWO,
THREE
}
Since I wanted to extend my application I have decided to move that to a different assembly (dll) and link it to my first assembly.
When I do that I get a weird result, when I desterilize classes that were serialized when the enum was in the first assembly, they all return first enum member by default.
Is there a solution on how to fix that? I even tried to parse it like:
(MyEnum)Enum.Parse(typeof(MyEnum), serializer.MyEnumType.ToString());
It has no effect.
PS. I use a binary serializer and the enum is in the same namespace and still have the same name.
[Serializable]
public class testClass
{
public MyEnum En { set; get; }
}
public class test
{
void Serialize(string file)
{
testClass ser = new testClass();
IFormatter formatter = new BinaryFormatter();
System.IO.FileStream stream = new FileStream(file, FileMode.Create, System.IO.FileAccess.Write, FileShare.None);
formatter.Serialize(stream, ser);
stream.Close();
}
void DeSerialize(string file)
{
IFormatter formatter = new BinaryFormatter();
testClass ser = new testClass();
System.IO.FileStream stream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.None);
ser = (testClass)formatter.Deserialize(stream);
stream.Close();
}
}