Help me to understand! I wanted to do my first program. I came across a website with step-by-step instructions on how to create a Hello World type program in Visual Basic. I did everything as it is written, and the code seems to be correct, but when debugging, such an error appears:

The first step in handling exception type "System.Windows.Markup.XamlParseException" in PresentationFramework.dll

More information: "Provide value on" System.Windows.Baml2006.TypeConverterMarkupExtens ion "threw an exception." Line number '16' and line position '132'.

If there is a handler for this exception, program execution can continue safely.

I did not find anything useful on the Internet. Maybe someone here will help. Only please, can explain in a language that is understandable not only to an experienced programmer. https://msdn.microsoft.com/ru-ru/library/jj153219.aspx - link to the site

Program Code:

Class MainWindow

Private Sub Button_Click(sender As Object, e As RoutedEventArgs) If RadioButton1.IsChecked = True Then MessageBox.Show("Hello.") Else : RadioButton2.IsChecked = True MessageBox.Show("Goodbye.") End If End Sub 

End class

Screen error that comes out after debugging: enter image description here

  • Thanks for the comment, fixed everything. - elesegen

1 answer 1

Ok, look, in .NET there is a mechanism for exceptions - this is an opportunity to extract "error" to the top in any place of the program. The calling code “above” can expect this error (somehow process it and go further) or not expect (and then the application will simply fall).

The mechanism of throwing "errors" -exclusions consists of several steps:

  • The very moment of throwing an exception - "first chance" (the first stage in the Russian translation) - is called like this, because this is really the first chance to learn about the exception somehow. Prior to that, just was not. By default - the debugger catches this chance, writes it to the log, but does nothing
  • Span exceptions up the call stack. If an exception was caught somewhere (by the Try / Catch construct), then the processing code is called and this ends everything
  • If no one has expressed the desire to handle the exception - then comes the "second chance" - he is the last. The debugger stops. If there is no debugger, then the application simply dies.

The behavior of the debugger in the first step is governed by settings in the Debug / Exceptions or Debug / Windows / Exception Settings dialog for each type of exception.

Your error in the log means that somewhere in the 16th line at the 132nd position of some XAML file there was an error, the XAML parser threw it and somewhere above the code this error was muffled. Those. "first chance" was, "second chance" was not.

Options for what to do with it:

  • try to find an error at random, by line number and position - it is unlikely that you have a lot of XAML files. Most likely this is some kind of typo / missing picture or something like that.
  • change the settings for handling exceptions of the type System.Windows.Markup.XamlParseException - and see what exactly and where falls.