| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| I'm getting an error when deserializing my objects: "The ObjectManager found an invalid number of fixups. This usually indicates a problem in the Formatter." I added a new object to a class that gets serialized and put the OptionalField attribute on that object. When trying to deserialize my object in an older version of our application that doesn't have this new class I get the above error but that's only when items have been added to the class. The class looks like this: public class MyCollection : BindingList<MyClass> { } public class MyClass { private string mystring; private CustomEnum myenum1; private CustomEnum2 myenum2; } public class ClassThatGetsSerialized { string member1; int member2; ... ... [OptionalField] MyCollection mycollection; .... } The error only occurs if object ClassThatGetsSerialized is deserialized by an older version that doesn't have the definition for MyCollection and if the member of ClassThatGetsSerialized.mycollection has items in it. If there are no items then the error does not happen. We use the OptionalField attribute in many places and it always works fine. Any ideas? Thanks, Joe |
|
#2
| |||
| |||
| Hello Joe, Thank you for reporting this issue to us. I've reproduced the symptom on my side with your instructions: **** App that serialize the object **** [Serializable] public class MyCollection : BindingList<MyClass> { } [Serializable] public class MyClass { private string mystring = "test"; } [Serializable()] class ClassThatGetsSerialized { public ClassThatGetsSerialized() { mycollection.Add(new MyClass()); } [OptionalField] MyCollection mycollection = new MyCollection(); public void Save() { System.IO.FileStream oStream = new System.IO.FileStream("c:\\test.txt", System.IO.FileMode.Create); IFormatter oFormatter = (IFormatter)new BinaryFormatter(); oFormatter.Serialize(oStream, this); oStream.Close(); } } ClassThatGetsSerialized obj = new ClassThatGetsSerialized(); obj.Save(); **** App that deserialize the object **** [Serializable()] class ClassThatGetsSerialized { public static ClassThatGetsSerialized LoadObject() { System.IO.FileStream oStream = new System.IO.FileStream("c:\\test.txt", System.IO.FileMode.Open); IFormatter oFormatter = (IFormatter)new BinaryFormatter(); ClassThatGetsSerialized obj = (ClassThatGetsSerialized)oFormatter.Deserialize(oS tream); oStream.Close(); return obj; } } ClassThatGetsSerialized obj = ClassThatGetsSerialized.LoadObject(); When I run the Deserialization app after running the Serialization one, I get the exception "The ObjectManager found an invalid number of fixups. This usually indicates a problem in the Formatter". The callstack is: at System.Runtime.Serialization.ObjectManager.DoFixup s() at System.Runtime.Serialization.Formatters.Binary.Obj ectReader.Deserialize(Head erHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) at System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter.Deserialize(S tream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) at System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter.Deserialize(S tream serializationStream) at ConsoleApplication1.ClassThatGetsSerialized.LoadOb ject() at ConsoleApplication1.Program.Main(String[] args) Joe, I suggest your submitting this issue to our feedback site, where the product group will further look into it: http://connect.microsoft.com/VisualStudio It's appreciated if you paste the feedback link here to benefit the community. Thanks Jialiang Ge (jialge@online.microsoft.com, remove 'online.') Microsoft Online Community Support ================================================= Delighting our customers is our #1 priority. We welcome your comments and suggestions about how we can improve the support we provide to you. Please feel free to let my manager know what you think of the level of service provided. You can send feedback directly to my manager at: msdnmg@microsoft.com. This posting is provided "AS IS" with no warranties, and confers no rights. ================================================= |
|
#3
| |||
| |||
| Are there any workarounds for this? ""Jialiang Ge [MSFT]"" <jialge@online.microsoft.com> wrote in message news:IOezNrNCJHA.1768@TK2MSFTNGHUB02.phx.gbl... > Hello Joe, > > Thank you for reporting this issue to us. I've reproduced the symptom on > my > side with your instructions: > > **** App that serialize the object **** > > [Serializable] > public class MyCollection : BindingList<MyClass> > { > } > [Serializable] > public class MyClass > { > private string mystring = "test"; > } > [Serializable()] > class ClassThatGetsSerialized > { > public ClassThatGetsSerialized() > { > mycollection.Add(new MyClass()); > } > > [OptionalField] > MyCollection mycollection = new MyCollection(); > > public void Save() > { > System.IO.FileStream oStream = new > System.IO.FileStream("c:\\test.txt", > System.IO.FileMode.Create); > > IFormatter oFormatter = (IFormatter)new BinaryFormatter(); > oFormatter.Serialize(oStream, this); > oStream.Close(); > } > } > > ClassThatGetsSerialized obj = new ClassThatGetsSerialized(); > obj.Save(); > > **** App that deserialize the object **** > > [Serializable()] > class ClassThatGetsSerialized > { > public static ClassThatGetsSerialized LoadObject() > { > System.IO.FileStream oStream = new > System.IO.FileStream("c:\\test.txt", > System.IO.FileMode.Open); > IFormatter oFormatter = (IFormatter)new BinaryFormatter(); > ClassThatGetsSerialized obj = > (ClassThatGetsSerialized)oFormatter.Deserialize(oS tream); > oStream.Close(); > return obj; > } > } > > ClassThatGetsSerialized obj = ClassThatGetsSerialized.LoadObject(); > > When I run the Deserialization app after running the Serialization one, I > get the exception "The ObjectManager found an invalid number of fixups. > This usually indicates a problem in the Formatter". The callstack is: > > at System.Runtime.Serialization.ObjectManager.DoFixup s() > at > System.Runtime.Serialization.Formatters.Binary.Obj ectReader.Deserialize(Head > erHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean > isCrossAppDomain, IMethodCallMessage methodCallMessage) > at > System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter.Deserialize(S > tream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean > isCrossAppDomain, IMethodCallMessage methodCallMessage) > at > System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter.Deserialize(S > tream serializationStream) > at ConsoleApplication1.ClassThatGetsSerialized.LoadOb ject() > at ConsoleApplication1.Program.Main(String[] args) > > Joe, I suggest your submitting this issue to our feedback site, where the > product group will further look into it: > http://connect.microsoft.com/VisualStudio > It's appreciated if you paste the feedback link here to benefit the > community. > > Thanks > Jialiang Ge (jialge@online.microsoft.com, remove 'online.') > Microsoft Online Community Support > > ================================================= > Delighting our customers is our #1 priority. We welcome your comments and > suggestions about how we can improve the support we provide to you. Please > feel free to let my manager know what you think of the level of service > provided. You can send feedback directly to my manager at: > msdnmg@microsoft.com. > > This posting is provided "AS IS" with no warranties, and confers no > rights. > ================================================= > |
|
#4
| |||
| |||
| Hello Joe, The old client app expects to know the type of MyClass. I find that a possible workaround in this issue is to declare MyClass as a struct (value type), instead of a class: public struct MyClass { private string mystring; private CustomEnum myenum1; private CustomEnum2 myenum2; } In this way, the old apps continue working fine. Please have a try and let me know whether the workaround is helpful to you. Have a nice weekend! Regards, Jialiang Ge (jialge@online.microsoft.com, remove 'online.') Microsoft Online Community Support ================================================= Delighting our customers is our #1 priority. We welcome your comments and suggestions about how we can improve the support we provide to you. Please feel free to let my manager know what you think of the level of service provided. You can send feedback directly to my manager at: msdnmg@microsoft.com. This posting is provided "AS IS" with no warranties, and confers no rights. ================================================= |
|
#5
| |||
| |||
| Making it a struct and re-saving the files seems to have worked. Thanks. ""Jialiang Ge [MSFT]"" <jialge@online.microsoft.com> wrote in message news MiCK$YCJHA.4896@TK2MSFTNGHUB02.phx.gbl...> Hello Joe, > > The old client app expects to know the type of MyClass. > I find that a possible workaround in this issue is to declare MyClass as a > struct (value type), instead of a class: > > public struct MyClass > { > private string mystring; > private CustomEnum myenum1; > private CustomEnum2 myenum2; > } > > In this way, the old apps continue working fine. Please have a try and let > me know whether the workaround is helpful to you. > > Have a nice weekend! > > Regards, > Jialiang Ge (jialge@online.microsoft.com, remove 'online.') > Microsoft Online Community Support > > ================================================= > Delighting our customers is our #1 priority. We welcome your comments and > suggestions about how we can improve the support we provide to you. Please > feel free to let my manager know what you think of the level of service > provided. You can send feedback directly to my manager at: > msdnmg@microsoft.com. > > This posting is provided "AS IS" with no warranties, and confers no > rights. > ================================================= > |
|
#6
| |||
| |||
| Sorry about taking so long to get back. Using a struct only sort of works. It does not make it easy for data binding to a data grid. ""Jialiang Ge [MSFT]"" <jialge@online.microsoft.com> wrote in message news MiCK$YCJHA.4896@TK2MSFTNGHUB02.phx.gbl...> Hello Joe, > > The old client app expects to know the type of MyClass. > I find that a possible workaround in this issue is to declare MyClass as a > struct (value type), instead of a class: > > public struct MyClass > { > private string mystring; > private CustomEnum myenum1; > private CustomEnum2 myenum2; > } > > In this way, the old apps continue working fine. Please have a try and let > me know whether the workaround is helpful to you. > > Have a nice weekend! > > Regards, > Jialiang Ge (jialge@online.microsoft.com, remove 'online.') > Microsoft Online Community Support > > ================================================= > Delighting our customers is our #1 priority. We welcome your comments and > suggestions about how we can improve the support we provide to you. Please > feel free to let my manager know what you think of the level of service > provided. You can send feedback directly to my manager at: > msdnmg@microsoft.com. > > This posting is provided "AS IS" with no warranties, and confers no > rights. > ================================================= > |
|
#7
| |||
| |||
| My solution was to re-write MyCollection class as MyCollection : CollectionBase, IBindingList. "Joe" <jbassking@noemail.noemail> wrote in message news:u2cNbuGCJHA.3348@TK2MSFTNGP04.phx.gbl... > I'm getting an error when deserializing my objects: > "The ObjectManager found an invalid number of fixups. This usually > indicates a problem in the Formatter." > > I added a new object to a class that gets serialized and put the > OptionalField attribute on that object. When trying to deserialize my > object in an older version of our application that doesn't have this new > class I get the above error but that's only when items have been added to > the class. > > The class looks like this: > public class MyCollection : BindingList<MyClass> > { > > } > > public class MyClass > { > private string mystring; > private CustomEnum myenum1; > private CustomEnum2 myenum2; > } > > public class ClassThatGetsSerialized > { > string member1; > int member2; > ... > ... > [OptionalField] > MyCollection mycollection; > > .... > } > > The error only occurs if object ClassThatGetsSerialized is deserialized by > an older version that doesn't have the definition for MyCollection and if > the member of ClassThatGetsSerialized.mycollection has items in it. If > there are no items then the error does not happen. > > We use the OptionalField attribute in many places and it always works > fine. > > Any ideas? > > Thanks, > Joe > |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.