- Home /
How do I track down an unspecified System.NullReferenceException?
That only shows up when I'm running on the device (iOS), and not in the editor? I'm getting an occasional (the worst kind) crash, upon returning to the game's main menu, and in the xCode output there's this...
**Unhandled Exception: System.NullReferenceException:**
...and that's all she wrote. If I could get it to happen when I'm previewing it in Unity it would tell me what caused the error, or if xCode barfed up its usual screenful of calls with the offending line highlighted, I could get this fixed, but right now it's a mystery. Before the error in the output, I've got this:
Unloading 1 unused Assets to reduce memory usage. Loaded Objects now: 29976. Operation took 850.822998 ms.
GameCenter logged in
Running LoadPrefsForOptionsScreen
(Filename: /Applications/buildAgent/work/14194e8ce88cdf47/Runtime/ExportGenerated/iPhonePlayer-armv7/UnityEngineDebug.cpp Line: 43)
2012-09-29 09:50:10.738 fourdsnake[1549:907] no Facebook session available
From that I'm guessing it is something with my prefs and connecting to Facebook, but the Facebook stuff is Prime31's and my prefs handling is kind of a mess so that doesn't help.
Can I force xCode to give me more detailed error messages in this case?
There's usually a stack trace/threads window you can open that you can then look through to give you more of a hint of where to look.
There should be in the left pane but as soon as it gets that NullReferenceException the app quits and the debug pane goes gray with "No Debug Session".
That in itself could be diagnostic if I knew what it meant, because I don't think that's normal behavior- usually NullReferenceExceptions result in a freeze, and only out of memory errors cause it to quit unexpectedly.
I'm having the same issue - did you ever find a solution or a reason for the crash?
Answer by Mortennobel · Apr 10, 2013 at 07:58 AM
I was able to track down my issue by changing Script Call Optimization from 'Fast but no exceptions' to 'Slow and safe' in the players settings.
Your answer
Follow this Question
Related Questions
iOS Xcode Error: Thread 1: EXC_BREAKPOINT 0 Answers
iOS game freezes on startup 0 Answers
Failed to load AOT module ... in aot-only mode. 1 Answer