Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by pikejd · Apr 14, 2011 at 01:07 AM · serializationxml

Why might XML Serialization result in crashes?

I'm working on loading/saving some data with XML serialization (and I'm coding using Unity JavaScript). I've run into an issue in that the editor would frequently (but not always) crash when doing some of these serialization operations. However, when I sat down to try and debug why, it suddenly stopped crashing, and I haven't been able to get it to crash since.

Here is roughly what I've been trying to do. Assume I have a custom class similar to this:

class MyClass
{
    var myVar;
    // more vars here; they're all basic types like int, float, String, etc.
}

My save (serialize) and load (deserialize) routines look something like this:

Load:

var xmlSerializer : XmlSerializer = new XmlSerializer(typeof(MyClass));
var fileStream : FileStream = new FileStream(Application.dataPath + "/" + "data.xml", FileMode.Open);
myObject = xmlSerializer.Deserialize(fileStream);

Save:

var xmlSerializer : XmlSerializer = new XmlSerializer(typeof(MyClass));
var streamWriter : StreamWriter = new StreamWriter(Application.dataPath + "/" + "data.xml");
xmlSerializer.Serialize(streamWriter, myObject);
streamWriter.Close();

Assuming that both those save and load routines are wrapped in try/catch blocks to catch exceptions, is there any reason anything I'm doing here would cause the editor to crash? Is there anything else that I should be doing with XML serialization that I'm not doing?

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image yoyo · Apr 14, 2011 at 03:37 AM 0
Share

Try adding error detection code (check for nulls etc.) If you're on Windows and you get a warning on startup about needing the service pack from a knowledge base article, then install it. If you're not on 3.3 then try an upgrade. $$anonymous$$y experience is that the editor does crash from time to time and you learn to live with it. :-p

avatar image TowerOfBricks · Apr 14, 2011 at 01:18 PM 0
Share

Also after a crash you can check the previous editor log. In the Console window, at the top-right is a button called "open editor log", open that. If you are on mac you should see a list to the left displaying some logs, you should see a previous editor log. On PC i'm not sure if the previous editor log is even saved, try to find out where the log is saved and open that before you restart Unity next time it crashes.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

How to save my serialized levels ? 1 Answer

Problem with XML Serialization in Android (XMLException) 0 Answers

Saving serializable class list at runtime. 1 Answer

Does XML Serialization Support "Class Object" Arrays? 1 Answer

whats the best way to save a large list of variables? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges