问题
So I originally encountered the issue described in this question: XmlSerializer giving FileNotFoundException at constructor
However, we just upgraded from Visual Studio (VS) 2013 Pro to VS 2019 Pro. Now, when I have all Common Language Runtime (CLR) Exceptions turned on (break when thrown) including System.IO.FileNotFoundException, I do not get a break on the exception. I thought it was something to do with the targeted .NET Framework (we also upgraded to .NET 4.8).
That said, I did a test:
- Created a test WinForms project in VS 2019 targeting .NET 4.5.2, our starting framework version.
- Add the following the default Form1 class:
public static readonly XmlSerializer kXMLSerializerList = new XmlSerializer(typeof(List<string>));
- Ensure all CLR Exceptions including System.IO.FileNotFoundException were on.
- Build.
- Launch the debugger in VS 2019.
Result: No break on an exception
OK, let's try VS 2013
- Start VS 2013
- Open the same project.
- Rebuild.
- Launch the debugger in VS 2013.
Result: XmlSerializer FileNotFoundException
So it doesn't seem to be a .NET Framework version dependency. An IDE dependency? That confuses me. Or is it a C# version dependency? Anyone have any clues?
回答1:
Bah. It was that "Just My Code" was checked.
I was thinking I had that unchecked, but I was wrong...sorry to all...
Hangs head in shame :(
来源:https://stackoverflow.com/questions/59736149/why-does-xmlserializer-not-cause-filenotfoundexception-in-visual-studio-2019