-->

A first chance exception of type 'System.Compo

2019-06-23 17:38发布

问题:

I have a .NET 4.0 WPF project.

When I open a FileDialog, choose some files and press the OK button, then I see in the output window this error:

A first chance exception of type 'System.ComponentModel.Win32Exception' occurred in WindowsBase.dll

OpenFileDialog fileDialog = new OpenFileDialog();
            fileDialog.Multiselect = true;

            DialogResult result = fileDialog.ShowDialog();
            if (result == DialogResult.OK)
            {

Why do I get that Exception before the if-statement?

回答1:

It sounds like you're seeing a Win32Exception which was raised and handled within the WPF application stack. I've seen this happen many times when debugging WPF applications. They make API calls which can fail, handle the exception and continue processing.

It's nothing to be concerned about unless the exception makes it way back to your code.