I have an open class that will not serialize correctly. When you try, the following exception is thrown:
The data contract type "MyProject.MyClass" is not serializable because it is not publicly available. A publication of this type will be fixed. In addition, you can make it internal and use the InternalsVisibleToAttribute attribute on your assembly to allow serialization of internal elements - see the documentation for more details. Keep in mind that this has certain security implications.
My class is publicly available though:
[DataContract]
public class MyClass
{
[DataMember]
public string Name { get; set; }
[DataMember]
private int Count;
public MyClass()
{
Name = string.Empty;
Count = 0;
}
}
Why do I get this exception when the class is explicitly open?