获取有关序列化错误的更多信息 [英] Getting more information on Serialization errors
问题描述
大家好,
我从事3D项目已有一段时间了.它已经工作了一段时间了.在此版本的早期开发中,我实现了保存并打开"功能,该功能可以通过将自定义3D对象文件保存到任何给定位置来工作.当我第一次添加此功能时,我制作了2个示例基本场景来对等进行测试.
现在,我已经使用了这些示例场景几个月了,应用程序显然反序列化它们也没有问题.:P最近,当我去实现一个显然在程序中运行良好的新测试场景时,问题就来了.我只是无法将其序列化为其他测试场景一样的状态.它使用与以前相同的代码保存过程.我什至将我所有的课程都标记为[Serializable()]
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();
}
我会发布更多代码,但我不知道还有什么其他内容:p
FileFormat.Serialize(FileWriter,this)行上的错误;
调试错误提供的帮助非常有限.
程序集``System.Drawing,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a''中的类型``System.Drawing.SolidBrush''未标记为可序列化.
如何找出未序列化的内容?
其他人也有类似的麻烦会有所帮助吗?
任何擅长调试的人都会给我一些提示(我是VS 2010的菜鸟及其调试人员)?
这个错误让我浪费了太多时间,无法自行解决.
我会很乐意回答任何疑问.
一百万个谢谢帮助我的人:)
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 :)
推荐答案
也许看看 ^ ],可能可以帮助您解决问题
Maybe have a look at sertool[^] by Kent Boogaart, might help you figure it out
基本上是为了解决该问题,是对Dylan解决方案的扩展,我使用该工具来跟踪错误绑定字段.
然后,我在给定字段上方标记了[field:NonSerialized()]
像这样:
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;
然后将其序列化:)
P.S还有另一种类型的错误提供了另一个问题.因为这是整个类中唯一使用该类型的变量,所以我也做了同样的事情.显然,如果带有[field:NonSerialized()]的字段包含您需要保存的数据,请找到另一种保存数据的方法,而不是二进制序列化:)
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 :)
这篇关于获取有关序列化错误的更多信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!