locked
Unhandled exception details in VS 2012 - Where is it? RRS feed

  • Question

  • User17374 posted

    I don't know if the following is a bug or just some unfortunate side effects or an unchecked checkbox somewhere...

    I was trying check out how Xamarin.Android (4.8.00013) is handling exceptions when I am running my code in Android simulator. (VS 2012 version: 11.0.60610.01).

    An exception results in an empty "An unhandled exception occurred" dialog. There's no chance to open the exception and read the message, or check inner exception. Not the wet dream of a UX designer...

    Which is not that bad if the call stack can be checked (simple case: exception thrown from a non-static method from a non-static class), and pressing break shows the line where the exception would be thrown.

    Now throw exception in a static method:

    1. the stack does not contain your static method

    2. you are left with a blank pop up ("Something bad has happened" - OK, then I try to do "Unsomething"...)

      A) If you press break you are thrown to an other dialog, saying "You must check disassembly window if you are trying to figure it out"

      checking disassembly window: it's blank...

      B) If you press Continue, it will result in the following dialog:

    "Loading..." will never finish. It's probably a bug.

    What can I do to find out what line has thrown the exception in the static case?

    Wednesday, August 7, 2013 3:17 PM

All replies

  • User20367 posted

    I have found the solution:

    Check Output window => "Show output from: Debug". I still consider it a bug as the dialog still did not load this:

    "UNHANDLED EXCEPTION: System.TypeInitializationException: An exception was thrown by the type initializer for CoreStuff.Loggers.Log ---> System.InvalidOperationException: ILogger factory was not initialized. Check your composition root!
    08-14 14:56:02.757 I/MonoDroid( 1053): Call stack:
    08-14 14:56:02.757 I/MonoDroid( 1053):    at CoreStuff.Factories.LoggerFactory.Create(System.String categoryName)
    08-14 14:56:02.757 I/MonoDroid( 1053):    at CoreStuff.Loggers.Log..cctor()
    

    etc. etc. But at least, I can figure out what the problem...

    Wednesday, August 14, 2013 3:06 PM
  • User13497 posted

    I am having a similar problem to this, if I hit an error I always get "An unhandled exception occured." but there's nothing in the debug log and the popup gives no details, I can't even get the stack trace to find the issue.

    Can someone help with this?

    Tuesday, November 19, 2013 10:40 AM
  • User59996 posted

    Anyone found a real solution to this issue? I'm seeing this behavior in Xamarin 3.1, VS 2013, Xamarin Studio 5.1.4 (latest version of everything right now).

    I have no way to see the stack trace to find the root cause of the issues I'm having, which is infuriating!

    The debug log shows nothing, just like @MarkRenwick. In Xamarin Studio, the app breaks at "System.Diagnostics.Debugger.MonoUnhandledExceptioninternal ()" and there's no trace of a useful stack trace (pun intended).

    Also note that my throwing code uses async/await. Maybe it has to do with this? After a quick test it seems the VS debugger breaks on the exception-throwing line when the line in question isn't in an async method (albeit with the same completely useless exception dialog). Did you guys have these issues with async code?

    How come no one from Xamarin answered to this post?

    Here is the full stack trace I'm seeing in Xamarin Studio. As you can see, there isn't much else than internal Mono stuff:

    System.Diagnostics.Debugger.MonoUnhandledException (ex=) in object.430500da-07c1-4a4a-b45b-c66f2ddc07d0 (Parameters=) in System.Runtime.CompilerServices.AsyncVoidMethodBuilder.AnonymousMethod0 (Parameters=) in Android.App.SyncContext.Post.AnonymousMethod0 (Parameters=) in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/163212a9/source/monodroid/src/Mono.Android/src/Android.App/SyncContext.cs:18 Java.Lang.Thread.RunnableImplementor.Run (Parameters=) in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/163212a9/source/monodroid/src/Mono.Android/src/Java.Lang/Thread.cs:36 Java.Lang.IRunnableInvoker.nRun (Parameters=) in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/163212a9/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Java.Lang.IRunnable.cs:71 object.430500da-07c1-4a4a-b45b-c66f2ddc07d0 (Parameters=) in

    Tuesday, July 22, 2014 4:20 PM
  • User32234 posted

    @michael_fortin? : this is exactly the same issue that I cant stand... it is killing me that when I have an exception, Xamarin Studio does not break on the affected line; all I'm left with is an unuseful stack trace (exactly like what you have pasted).

    Are the Xamarin Engineers reading these threads ??

    Thursday, August 7, 2014 10:24 AM
  • User209 posted

    Don't press break, keep pressing continue and it will spit out the stack trace in the output window.

    Thursday, August 7, 2014 10:53 AM
  • User59996 posted

    @Cheesebaron Like I mentioned in my previous reply, the stack trace that's printed to the output window is all internal mono code, not app code. This means we can't see what exception was thrown and where, only that there was an exception.

    The workaround you mentioned works for "normal" exceptions in non-async code, through.

    Thursday, August 7, 2014 1:28 PM
  • User70171 posted

    Anybody from Xamarin? As @michael_fortin? said, the stack trace is limited to mono internal. For example I am getting exception in Parse component, but the stack trace I get after keep hitting 'Continue' is limited to Mono - there is no way to know what's going wrong in Parse.

    Saturday, August 23, 2014 2:58 AM
  • User64283 posted

    I know this is a really old thread but I keep seeing this too. I couldn't find a bug report about it, so I've logged one here

    Friday, October 3, 2014 6:18 AM
  • User17978 posted

    Did anyone find a solution to this problem, or is it still a dead end ?

    Wednesday, May 6, 2015 7:05 PM
  • User123071 posted

    It appears I have a similar issue; Visual Studio Premium 2013 with latest version of Xamarin. NullReferenceExceptions when debugging on an Android device never break to the line where the exception occurred. A stack trace can usually be found by pressing break and checking the output window, but debugging is complicated by being unable to halt execution and inspect the values of local variables.

    I am unsure if this is intended behavior or a real issue, but the symptoms are very similar to what is described here. It's not a showstopper, but it does complicate debugging quite a bit.

    Monday, May 11, 2015 1:08 PM
  • User95501 posted

    Am facing the same issue in Visual Studio 2013. Have anyone found a solution for this?

    Wednesday, May 20, 2015 10:53 AM
  • User92622 posted

    You can find the stacktrace in the Android Device Logging window (go to View->Other windows->Android Device Logging...) and filter by "MonoDroid".

    Tuesday, May 26, 2015 5:56 AM
  • User125416 posted

    How log will it take until xamarin actually understands that this is very important and we need it!!!!!!! We need to be able to see the callstack when an exception happens and be able to walk the stack to see variables. This is standard in visual studio for windows applications. Is it that hard or are you plain ignorant?!?!

    Saturday, July 11, 2015 8:39 AM
  • User129504 posted

    Why is this problem still unresolved? This slows me down too much. How can I deliver my work before the deadline if it keeps crashing on such an exception, I cannot track down its details and origin and therefore I do not know how to solve it?

    Friday, March 4, 2016 10:29 AM
  • User83 posted

    My solution was to switch back to a Mac for Android development, at least until this is fixed for my code gets stable enough to not throw confusing exceptions (!!). Testing in the Mac showed that my exception was in async code.

    Monday, November 28, 2016 4:02 AM
  • User281159 posted

    VS2015 and still the same issue...

    Sunday, December 4, 2016 1:19 AM
  • User278219 posted

    I'm seeing this issue with VS2015 Update 3 and Xamarin 4.2.2

    As @Cheesebaron mentioned earlier, keep hitting continue. Then when Visual Studio stops debugging, you'll see the stack trace in the Output Debug window. You might have to scroll up a little. Search for Unhandled Exception. Here's what I see:

    Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidProgramException: Invalid IL code in System.ComponentModel.DataAnnotations.ValidationContext:.ctor (object,System.Collections.Generic.IDictionary`2): method body is empty.

    at ..... (stack trace of my own code)

    I can now see that the exception originated from my own source code, so I know what I have to fix.

    Thank you @Cheesebaron for posting! This helped me tremendously!

    Thursday, January 26, 2017 4:25 PM
  • User278219 posted

    Also, in Visual Studio go to Help > Xamarin > Open Logs. A folder will open and the exceptions you're looking for are in those files.

    Thursday, January 26, 2017 9:21 PM
  • User307820 posted

    2017 Update 2 and I'm still seeing this issue.

    Wednesday, May 24, 2017 6:41 PM
  • User327979 posted

    this is really frustrating, this post is 5 years old but the problem still exist, I'm using VS 2017 and have them same issue, no exception details no stack trace, when we don't know what the problem is how can we fix the problem?

    Friday, June 2, 2017 12:09 PM
  • User191145 posted

    i have same issue https://forums.xamarin.com/discussion/97833/system-aggregateexeption-one-or-more-errors-occurred#latest vs 2015 update3

    Friday, June 16, 2017 5:07 PM
  • User323063 posted

    In VS 2017. I just hit the continue button until the app stops. And on the Output console, you can see stack traces, including information about the app code.

    Monday, June 19, 2017 5:41 AM
  • User12883 posted

    Any fix for the above issue, cannot see any log + I am using the terrible MVVMCross which is making life worse

    Thursday, June 22, 2017 1:27 AM
  • User335619 posted

    So I ran into this myself, and was growing increasingly depressed as I read this thread. Years of posts with no resolution!

    But I found something that worked: I opened my Exception Settings and enabled Break When Thrown for pretty much everything.

    Turns out I had an ordinary, trivially-fixed null reference exception being thrown in my C# code. Without "Break When Thrown", that was bubbling up and I'd get an empty, worthless "An unhandled exception occurred." With "Break When Thrown" enabled, the program stopped in the debugger on the line of code that threw the error, I fixed it, and moved on. Huge relief.

    Hopefully this works for the next guy who's googling leads him here.

    Thursday, July 20, 2017 4:05 PM
  • User343755 posted

    @Mud said: So I ran into this myself, and was growing increasingly depressed as I read this thread. Years of posts with no resolution!

    But I found something that worked: I opened my Exception Settings and enabled Break When Thrown for pretty much everything.

    Turns out I had an ordinary, trivially-fixed null reference exception being thrown in my C# code. Without "Break When Thrown", that was bubbling up and I'd get an empty, worthless "An unhandled exception occurred." With "Break When Thrown" enabled, the program stopped in the debugger on the line of code that threw the error, I fixed it, and moved on. Huge relief.

    Hopefully this works for the next guy who's googling leads him here.

    I am that guy and it works! Thank you so much.

    Friday, October 27, 2017 9:39 AM