Jump to content
  • Advertisement
Sign in to follow this  
Goober King

[.net] deserialize

This topic is 3710 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok I went off and got stuck again. So I recently asked for some direction on how to save an object to disk for later use, which led me to serialize /deserialize. After writing the saver and secondary loading application, it is looking like I may need to store the objects in a dll since I am reading and writing in two independently compiled programs(is this accurate?). Now here's the(a) dumb question I can't seem to answer. How does one import a dll file created with C# ? The DllImport examples I've used and found don't really fit the class structure. Do I even need to do that? Are there rules on how I should lay out such a dll? I'm definitely missing some key info on something that may qualify as basic, but I need some guidance all the same.

Share this post


Link to post
Share on other sites
Advertisement
Yes, in order to deserialize the objects the program will have to know where to find the information about the types.

DllImport is only for working with native DLL's. If you write a DLL in C#, you don't need to use it. All you need to do is add a reference to it in your application. Right click the references folder in the solution explorer, click Add Reference, the browse tab, and find the dll from your library project with the types in it. Or, if the dll project is part of the same solution, just select it from the Projects tab in the Add Reference dialog.

Share this post


Link to post
Share on other sites
I wondered about that. I guess I should have been able to figure that one out though. Anyway I'll give it a go tonight. thank you.

Share this post


Link to post
Share on other sites
I have one more bit I would like clarification on. If I serialize a set of objects does it need to go in its own file? Currently I embed the data in a file along with other information, but I'm getting thrown an error saying

Quote:

Binary stream '0' does not contain a valid BinaryHeader. Possible causes are invalid stream or object version change between serialization and deserialization.


I'm currently using objects defined from the same dll in both programs.

edit
wait it looks like I'm off a byte on my read for some reason. Got it kinda working using a separate file for now.

[Edited by - Goober King on June 19, 2008 10:55:25 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!