Click here to Skip to main content
15,888,285 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello All,

I have been working on a 3D project for some time now. It has been working for quite a while. In my early developments of this version I implemented a Save and Open feature which works by saving my custom 3D object file to any given location. When I first added this feature I made 2 sample basic scenes to do tests on etc.

I have now used these sample scenes for a couple of months and the application clearly has no problem de-serializing them :P The problem has come recently when I went to implement a new test scene which clearly works well in the program. I just cannot serialize it into a state like my other test scenes. It's using the same code save procedure as before. I have even marked all my classes as [Serializable()]

public void Save(string FileDirectory)
        {
            Stream FileWriter = File.Open(FileDirectory, FileMode.Create);
            BinaryFormatter FileFormat = new BinaryFormatter();
            FileFormat.Serialize(FileWriter, this);
            FileWriter.Close();
        }


I would post more code but I wouldn't know what else to post :p

Errors on the line FileFormat.Serialize(FileWriter, this);
The debug error's provide very limited help.
Type 'System.Drawing.SolidBrush' in Assembly 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable.

How can I find out what its not serializing?
Any body else have a similar trouble that would help?
Any body good at debugging give me tips (I'm a noob with VS 2010 an its debugging)?

Too many lost hours with this bug to solve on my own.
I will happily answer any queries.
A million thank you's to the person that helps me :)
Posted

Maybe have a look at sertool[^] by Kent Boogaart, might help you figure it out
 
Share this answer
 
v2
Comments
Thomas.D Williams 7-Apr-11 11:45am    
I shall have a look into this and report you on my progress. Thank you for the link :)
Thomas.D Williams 7-Apr-11 12:18pm    
Ok, I used the tool in the link to track down the given field in my custom class. Worked well... Basically gave a field name for me to hunt down with Ctrl + F :p
Thank you for the help
Basically to solve the problem as an extension to Dylan's solution I used the tool to track down the error bound field.

I then just marked above the given field with [field:NonSerialized()]
like so:
[field:NonSerialized()]
Graphics DrawMethod;


It then serialized :)


P.S there was another type in another error giving a problem. As this was the only variable in the entire class using that type I did the same thing to that. Obviously if the field with [field:NonSerialized()] on contains data you need to save find another way to save the data other than Binary Serialization :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900