开发者

First chance exception happened in the constructor of XMLSerializer [duplicate]

开发者 https://www.devze.com 2023-01-31 18:16 出处:网络
This question already has answers here: Closed 12 years ago. Possible Duplicate: XmlSerializer giving FileNotFoundException at constructor
This question already has answers here: Closed 12 years ago.

Possible Duplicate:

XmlSerializer giving FileNotFoundException at constructor

I received the first chance exception when I used XMLSerializer,

XMLSerializer xml = new XMLSerializer(typeof(A))

A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll

Additional information: Could not load file or assembly 'A.XmlSerializers, Version=1.0.0.0, Cul开发者_StackOverflow中文版ture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

It is OK, but it is annoying when debugging. What is the reason?


First chance means the program hasn't been able to deal with it yet, the debugger comes first. When you let it through, the app will deal with it nicely, so you don't get errors.

In this particular case, the thing is that XMLSerializer can use assemblies with compiled schema information in them. So it tries to load the assembly just in case it exists. If not, it's not a problem, but if it does, it will use that and it will be faster. When you compile your project in release mode, you often get XMLSerializer assemblies.

You should set up Visual Studio to ignore thrown (1st chance) exceptions, and only break on unhandled ones.

0

精彩评论

暂无评论...
验证码 换一张
取 消