Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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, Culture=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?

like image 933
user496949 Avatar asked Dec 23 '10 08:12

user496949


1 Answers

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.

like image 60
fejesjoco Avatar answered Oct 08 '22 08:10

fejesjoco