Skip to main content
GameDev.net gamedev.net
🔒 Locked

Deserialization error in another application

Started by SonicD007 Jan 28, 2012 at 2:01 AM 2 replies 2.3k views
Original Post
SonicD007
SonicD007

I have no problem with serializing and deserializing from the same application. The problem comes in when I try to serialize from one application and deserialize in the other. Both applications have the same classes that are being serialized/deserialized. Looking at the exception being thrown, I think the problem lies in the assembly info for each project. The level editor project serializes it, then in the tilesettest project, the exception thats thrown complains about the assembly information not being CLevel editor. Any idea how to fix this? Thanks.

Here is exactly what it says:

System.Runtime.Serialization.SerializationException: Unable to find assembly 'Level Editor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

at System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly()

at System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(BinaryAssemblyInfo assemblyInfo, String name)

at System.Runtime.Serialization.Formatters.Binary.ObjectMap..ctor(String objectName, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable)

at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped record)

at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryHeaderEnum binaryHeaderEnum)

at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
GWDev
GWDev
Hello SonicD007,

this sounds like you need to make sure both projects reference the same assembly. Are you sure that it is really the same file or did you copy it and may now have different versions?

--GWDev
SonicD007
SonicD007
I haven't done anything with the assembly. I just copied the Map class, layer, etc that has to be serialized/deserialized. How do I have my project reference that assembly?

EDIT: after some googling, it seems I need to put the classes I want to serialize/deserialize into a .dll and reference it like that

EDIT2: For anyone in the future that has this problem, I fixed this by putting the classes being serialized/deserialized into a .dll and referencing that .dll in both projects instead of having the source code for the classes in the project tree.
GWDev
GWDev

I haven't done anything with the assembly. I just copied the Map class, layer, etc that has to be serialized/deserialized. How do I have my project reference that assembly?


Yes, that is what i meant. So it is not the same assembly.
Just add the output from the project with the Map-class in it as a reference to the other project. This might be unwise if you only need one class out of a large project. In that case you can move your class files to a game lib project in the solution and reference the build output. Now Visual Studio makes sure to rebuild if there were changes to the dll.


EDIT: after some googling, it seems I need to put the classes I want to serialize/deserialize into a .dll and reference it like that


Yes, this is one way to do it.


EDIT2: For anyone in the future that has this problem, I fixed this by putting the classes being serialized/deserialized into a .dll and referencing that .dll in both projects instead of having the source code for the classes in the project tree.


Make sure you only have one location from where all the time for every project only the most recent version is referenced. Maybe even build the dll directly to that location.

--GWDev

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.