0

In visual studio 2017 with xamarin every time I got an error I got into Break Mode without any information regarding the exception.

enter image description here

According to this question in a different forum you can get meaningful message about the error, but doesn't specify how:

https://forums.xamarin.com/discussion/96478/using-visual-studio-2017-any-coding-error-results-in-the-application-is-in-break-mode

enter image description here

But I try same code in my system and only got break mode: what I have to do?

I create a button in the MainActivity class, and the break pause happen when try access a list element in the empty list.

 public class MainActivity : Activity
    {
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            Button button = FindViewById<Button>(Resource.Id.getWeatherButton);

            button.Click += async (sender, e) =>
            {
                var x = new List<int>();
                var y = x[3];
            };
        }
Juan Carlos Oropeza
  • 47,252
  • 12
  • 78
  • 118
  • 2
    I'm confused. Your second image literally shows you what the exception is (`System.ArgumentOutOfRangeException`). What is the problem? – maccettura Nov 27 '17 at 20:49
  • 1
    @maccettura My VS show break mode. The image is from a different system, not mine. I wish have something like that – Juan Carlos Oropeza Nov 27 '17 at 20:50
  • Possible duplicate of [Disable "Break Mode" page in VS2015](https://stackoverflow.com/questions/36204009/disable-break-mode-page-in-vs2015) – mjwills Nov 27 '17 at 20:53
  • @mjwills Can you be more specific on which answer can help me with this? I already saw that question and doesn't seem related to this. In Visual Studio for windows form I can get into break mode without problem, the problem here is in Xamarin I can't watch the Exceptions. – Juan Carlos Oropeza Nov 27 '17 at 20:56
  • The error message includes the text "but there is no code to show because all threads were executing external code". Either the exception is not caused by your code, or the debugging information is missing, causing visual studio not know which code is executed. However, the screenshot also shows a "copy details" link. Click that and paste your exception into this question, it might give more information. – wimh Nov 27 '17 at 20:57
  • What happened when you tried the suggestions in that link @juanCarlosOropeza ? What about in https://stackoverflow.com/questions/31580182/visual-studio-2015-rtm-debugging-not-working ? – mjwills Nov 27 '17 at 20:57
  • Could be that you need to change your exception settings in visual studio. The exception happens in another thread and thus does not provide exception info in the debugger.. – IceCode Nov 27 '17 at 21:04
  • @Örvar Do you know what exception setting should I change? The exception should be on the same thread. I can see the code and go step buy step just before `var y = x[3];` – Juan Carlos Oropeza Nov 27 '17 at 21:13
  • @JuanCarlosOropeza Check the following page: https://msdn.microsoft.com/en-us/library/x85tt0dd.aspx?f=255&MSPPError=-2147217396 Perhaps some of the exceptions need to be added.. – IceCode Nov 27 '17 at 21:17
  • @mjwills Do you still think this is a duplicated question? If so please be specific on which answer can help here. If dont .. please remove the vote to avoid be close. Thanks. – Juan Carlos Oropeza Nov 27 '17 at 21:21
  • @mjwills Than please can you be specific on which answer, so I can explain why doesnt solve my problem. – Juan Carlos Oropeza Nov 27 '17 at 21:26
  • @mjwills The first one say the problem is `Now when I pause a running app to work on it` I dont have problem when pausing the app. I can debug step by step. The problem is when the error occours the screen become as the first picture and doesnt show the exception. The second link I already have those boxes already checked. – Juan Carlos Oropeza Nov 27 '17 at 21:31

1 Answers1

2

The post literally states the contrary, you can't get any meaningful info.

The problem lies on the architecture of a Xamarin application, it is some kind of "wrapper" around native classes, so when an exception is caused in the native code no debug info exists.

The best you can do is, continue, let the program crash, go to the output pane and then read the exception, there you will find the stack trace and concrete data.

Gusman
  • 14,905
  • 2
  • 34
  • 50
  • What post are you referring too? The image I add show the meaningful error directly on the screen. – Juan Carlos Oropeza Nov 27 '17 at 21:05
  • The post you have added, read the last comment. It depends on the exception type, if it's on managed code then the normal debug will happen, else the "break mode" page will show up. – Gusman Nov 27 '17 at 21:07
  • You mean this one `I also get the expected break at the offending line above, but in general I have to agree with Andrew. Debugging in Android and iOS is near impossible, since you don't get a call stack or exception details if it occurred in external code. This can't be by design.` ?? That specify if happen in external code. `var y = x[3];` isnt external code – Juan Carlos Oropeza Nov 27 '17 at 21:10
  • I check the output window https://i.stack.imgur.com/qJRtM.png, no information regarding the Exception neither – Juan Carlos Oropeza Nov 27 '17 at 21:11
  • @JuanCarlosOropeza And the `var y = x[3];` exception will show the normal debug (read the entire post, the user just pasted that code to create an example and every body told him that will show the normal debug). Let the application to crash, then go back to the output pane, then you will get the stack trace. – Gusman Nov 27 '17 at 21:16
  • I told you. I try the same code and didn't get any Exception. I get the Break Mode I show you on the first picture. I let the application crash and the output panel doesnt show the stack trace neither. Didnt you saw the output panel picture? – Juan Carlos Oropeza Nov 27 '17 at 21:18
  • @JuanCarlosOropeza Then the exception is happening in external code, you can even read it on that pane "all threads where executing external code". I would assume that's because the `async` modifier. – Gusman Nov 27 '17 at 21:24