c# - How can I deserialize an interface type? -
I serialize a square containing model
like IModel
But when I try to dysurize it, I get the following exception:
System time to time. Serialization. Serialization exception: 'MYN.imodel' in assembly 'MYN.Defs, Version = 1.0. 0.0, culture = fair, public keynote = zero 'is not marked as serializable.
This is a binary serialization model
Serialized is marked as Qualitatively obviously not emodel.
So what's the solution, what am I doing wrong?
P.S. Why does it try to serialize or deserialize the interface in any way? An NM is not found in the interface.
This makes sense to get that error, because < Code> IModel property can refer to different classes and there is no guarantee that they are all serial
OK, I gave it a try and our Pass:
Testress error, it works on my computer.
interface IFoo {} [serialable] class CFoo: IFoo {} [Serializable] class bar {public IFoo Foo {get; Set; }}
and bar serialize and deserialize fine.
Bar = new times (); B.Fu = new CFU (); (Var s = new System.IO.MemoryStream ()) using {var bf = new system.timetime. SERIALIZATION.Formatories.Binary.BinaryFormer (); Bf.Serialize (S, B); S.Position = 0; B = (bar) BF Diarrheal (s); Console.WriteLine ("OK"); }
Then, what is different from your IModel
and model
Comments
Post a Comment