|
Bugzilla – Full Text Bug Listing |
| Summary: | BinaryFormatter doesn't deserialize objects with nullable types | ||
|---|---|---|---|
| Product: | [Mono] Mono: Class Libraries | Reporter: | Mika Aalto <mika.aalto> |
| Component: | CORLIB | Assignee: | Mono Bugs <mono-bugs> |
| Status: | RESOLVED DUPLICATE | QA Contact: | Mono Bugs <mono-bugs> |
| Severity: | Normal | ||
| Priority: | P5 - None | CC: | forgotten_oDRaEXi7Ku |
| Version: | 2.6.x | ||
| Target Milestone: | --- | ||
| Hardware: | x86 | ||
| OS: | Other | ||
| Whiteboard: | |||
| Found By: | --- | Services Priority: | |
| Business Priority: | Blocker: | --- | |
| Marketing QA Status: | --- | IT Deployment: | --- |
| Attachments: | Testing application | ||
Hello Mika, the testcase is incomplete, could you share also the source code to generate the bin file that you bundled in it? Thanks! I deduced the initialization of the object, it's:
AddressBookContact abc = new AddressBookContact();
abc.Id = 0;
abc.FirstName = "Unit";
abc.LastName = "Testing";
abc.State = ContactState.Unknown;
abc.PrimaryPhoneNumber = "0405087124";
abc.MobilePhoneNumber = "050123456789";
abc.HomePhoneNumber = "+3589123456";
abc.SecondaryMobilePhoneNumber = "";
abc.FaxNumber = "123";
abc.EmailAddress = "unit.test@ccxtech.fi";
abc.OrganizationId = 1;
abc.Title = "Tester";
abc.UserId = 1;
abc.ContactGroupIds = new List<int>();
And I confirm it fails in master.
I'll try to isolate the testcase.
I have isolated the problem to just nullable types.
This simple class fails to be deserialized on mono when assigning to the field the value 1:
[Serializable]
public class AddressBookContact
{
public int? UserId;
}
Actually it's a dupe, this all sounded very familiar to me... *** This bug has been marked as a duplicate of bug 552891 *** |
Created attachment 334470 [details] Testing application User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.6) Gecko/20091216 Mandriva Linux/1.9.1.6-0.1mdv2010.0 (2010.0) Firefox/3.5.6 Object serialized in MS .NET environment using BinaryFormatter can't be deserialized with mono. Attached example application contains data.bin file which is object serialized in MS .NET. Running attached application deserializes this file correctly with MS .NET but not with mono. Reproducible: Always Steps to Reproduce: 1. Run attached example application 2. 3. Actual Results: Unhandled Exception: System.Runtime.Serialization.SerializationException: Unexpected binary element: 0 at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObject (BinaryElement element, System.IO.BinaryReader reader, System.Int64& objectId, System.Object& value, System.Runtime.Serialization.SerializationInfo& info) [0x00000] in <filename unknown>:0 at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadValue (System.IO.BinaryReader reader, System.Object parentObject, Int64 parentObjectId, System.Runtime.Serialization.SerializationInfo info, System.Type valueType, System.String fieldName, System.Reflection.MemberInfo memberInfo, System.Int32[] indices) [0x00000] in <filename unknown>:0 at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObjectContent (System.IO.BinaryReader reader, System.Runtime.Serialization.Formatters.Binary.TypeMetadata metadata, Int64 objectId, System.Object& objectInstance, System.Runtime.Serialization.SerializationInfo& info) [0x00000] in <filename unknown>:0 at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObjectInstance (System.IO.BinaryReader reader, Boolean isRuntimeObject, Boolean hasTypeInfo, System.Int64& objectId, System.Object& value, System.Runtime.Serialization.SerializationInfo& info) [0x00000] in <filename unknown>:0 at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObject (BinaryElement element, System.IO.BinaryReader reader, System.Int64& objectId, System.Object& value, System.Runtime.Serialization.SerializationInfo& info) [0x00000] in <filename unknown>:0 at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObject (BinaryElement element, System.IO.BinaryReader reader, System.Int64& objectId, System.Object& value, System.Runtime.Serialization.SerializationInfo& info) [0x00000] in <filename unknown>:0 at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadNextObject (BinaryElement element, System.IO.BinaryReader reader) [0x00000] in <filename unknown>:0 at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObjectGraph (BinaryElement elem, System.IO.BinaryReader reader, Boolean readHeaders, System.Object& result, System.Runtime.Remoting.Messaging.Header[]& headers) [0x00000] in <filename unknown>:0 at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.NoCheckDeserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler) [0x00000] in <filename unknown>:0 at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream) [0x00000] in <filename unknown>:0 at SerializationTest.MainClass.Main (System.String[] args) [0x00000] in <filename unknown>:0 Expected Results: Class deserialized