Closed claudiofc closed 9 years ago
This will not work if you are using BinaryFormatter to serialize. ConfuserEx is probably renaming several properties so you are not able to open a saved project file from the unconfused version in the confused version and vice versa.
I am using XML serialization to avoid this problem, but would suggest to exclude all classes that are serializable from the renaming confusion.
thx for the reply. I have some addition questions that not only can I open a saved project file from the unconfused version in the confused version and vice versa, but also I cannot open a saved project file from a confused version to another confused version(simply confuse the program for a second time, it won't read the previous confused version). I don't know if only BinarySerialization suffers from that or would XML Serial has the same problem? Thanks again~
That could be an effect of obfuscating the class you are serializing. I think ConfuserEx uses by default a random seed for obfuscating, therefore the renaming output could be different for every confusion. When the property names are changing, the class signature is changing too and you cannot deserialize anymore since the class has different named properties and is incompatible.
As mentioned before: You probably need to turn off the Rename confusion for this class (and eventually other classes that are getting serialized via child properties) or you use XML serialization.
When using XML serialization you can configure the serialization with attributes and define how a property is serialized to XML or you also can do that by code if you want. The serializer is using the configuration defined by the attributes and is no longer relying on the property names - therefore XML serialization will always work.
See http://www.codeproject.com/Articles/483055/XML-Serialization-and-Deserialization-Part
many thx~
Hi, Apart from the suggestion of @barnacleboy, you could also explicitly set the random seed. As long as the type name remains unchanged, the output name should be the same.
My program uses Serialization to save projects. After I used ConfuserEx to generate the confused version, it cannot load(deserialized) the previous saved project correctly. I wander if there are some solutions to it.