C# Serialization seems to fail
Translates state machine into a target programming language.
Brought to you by:
cwrapp
Hello,
Great software, but it seems like I'm having trouble with serializing and deserializing the the current state and restoring it.
It seems that the State it self is not serialized. I followed the example from the manual and implemented this on the C sharp example EX1:
The first cycle I use the create state machine, the second cycle is after serialization and deserialization.
I included the test project with this post.
Another thing is that the AppClassContext which is generated by the SMC isn't marked [Serializable]
state processing after initializationThe string "1Z010E111" is not acceptable.
state processing after serialize/deserializeThe string "1Z010E111" is
Exception: statemap.StateUndefinedException
--------------------------------------------------------------------
statemap.StateUndefinedException: Error in the application.
at AppClassContext.get_State() in d:\EX1\AppClass1.cs:line 22
at AppClassContext.EnterStartState() in d:\EX1\AppClass1.cs:line 62
at AppClass.CheckString(String inputString) in d:\EX1\AppClass.cs:line 74
at checkstring.Main(String[] args) in d:\EX1\checkstring.cs:line 74
press any key to continue...
The problem is not with the generated C# code but the C# library itself:
C Sharp
The [NonSerialized] will be dropped for release 6.4.0 and the dlls updated.
The [Serializable] is added to the AppClassContext when the SMC "-serial" option is used. See the SMC Programmer's Manual section 9: Be Persistant! which explains how to serialize/deserialize a C# FSM. You should be serializing the AppClass instance and not the AppClassContext by itself.
Last edit: Charles Rapp 2014-09-14
Thanks works like a charm!