- Home /
ArgumentOutOfRangeException when calling CrashReport.reports
Using C# to read the Unity CrashReport.reports array, it will throw the following exception/stack when running on an iOS device:
ArgumentOutOfRangeException: Argument is out of range.
System.DateTime.AddTicks (Int64 value)
System.DateTime.AddMilliseconds (Double value)
System.DateTime.AddSeconds (Double value)
UnityEngine.CrashReport.PopulateReports ()
UnityEngine.CrashReport.get_reports ()
I'm using a nearly identical call as documented here: http://docs.unity3d.com/Documentation/ScriptReference/CrashReport.html
This is the line of code failing:
var reports = CrashReport.reports;
In the CrashReporter.h, I have the following:
#define ENABLE_IOS_CRASH_REPORTING 1
#define ENABLE_CUSTOM_CRASH_REPORTER 1
#define ENABLE_CRASH_REPORT_SUBMISSION 0
In case it's relevant, my Player Settings have:
Script Call Optimization is "Slow and Safe"
I'm using Unity 4.3.4f1 on a trial Pro License. I'm building to iOS with default settings and compiling with Xcode 5.1 (5B130a). My iOS device is an iPhone 5 (MD644LL/A) running iOS 7.1 (11D167).
Any assistance is appreciated! Thanks :D
Update #1:
As requested, here is my exact code where I call into CrashReport.reports.
To clarify, the exception is thrown when I call "CrashReport.reports"- not when I attempt to iterate on the return value. The ArgumentOutOfRangeException stack above indicates the crash is within the Unity framework, not my script.
void OnGUI() {
GUILayout.Label(labelText);
GUILayout.Label("Crash reports:");
// this call is crashing with ArgumentOutOfRangeException
va reports = CrashReport.reports;
if (reports == null)
return;
foreach (var r in reports) {
GUILayout.BeginHorizontal();
GUILayout.Label("Crash: " + r.time);
if (GUILayout.Button("Log")) {
Debug.Log(r.text);
}
if (GUILayout.Button("Remove")) {
r.Remove();
}
GUILayout.EndHorizontal();
var report = CreateReport(r.text, r.text);
SendReportToServer(report);
}
}
Also, perchik (thanks!) mentioned it could be license related. The docs say:
CrashReport API requires Unity Pro license for target platform.
This may very well be related, as I'm only using a trail version of Unity Pro without the iOS Pro Addon. I'll update as soon as I can verify this is the case or not. Either way, it's a strange way to abort the call if not licensed for it :)
Is this not a good question? Am I missing some critical information for assistance? Is this not the right place to get assistance for this kind of problem? Am I just being impatient?
Calm down.
Now, post more code. Your error is an index error, but your code doesn't access it. Somewhere in your code you do something like reports[i]
or something and for whatever reason i
is longer than the number of reports.
However, I'd note that the documentation says that you need Unity with iOS pro. (which is different than Unity Pro with iOS)
Thank you perchik. I've added "Update #1" to address your response. This may very well be license related, as you suggested.
yeah, my understanding of that line in the docs is that you have to have Pro for iOS...I've gotten caught in similar binds before when I had Pro, but not Android Pro. It's strange that it's throwing a out of range exception, but sometimes the licensing related content throws odd errors
Seems my trial should cover this, from http://unity3d.com/unity/download (emphasis $$anonymous$$e):
The free version of Unity for Windows. Includes publishing support for iOS, Android, Windows Store, Windows Phone, BlackBerry, desktop and Web, and a 30 day trial of Unity Pro (with Pro publishing for iOS, Android, Windows Store, Windows Phone and BlackBerry).