中的XMLSerializer的构造函数第一次机会异常发生 [英] First chance exception happened in the constructor of XMLSerializer

查看:451
本文介绍了中的XMLSerializer的构造函数第一次机会异常发生的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  

可能重复:
  <一href="http://stackoverflow.com/questions/1127431/xmlserializer-giving-filenotfoundexception-at-constructor">XmlSerializer在构造函数中给FileNotFoundException异常

当我使用的XMLSerializer我收到的第一次机会异常,

  XMLSerializer的XML =新的XMLSerializer(typeof运算(A))
 

  

有一个第一次机会异常类型   System.IO.FileNotFoundException   出现在mscorlib.dll

     

信息:无法加载   文件或程序集A.XmlSerializers,   版本= 1.0.0.0,文化=中立,   公钥= null或它的一个   依赖性。系统不能找到   该文件中指定。

这是确定的,但在调试的时候很是烦人。这是什么原因?

解决方案

第一次机会是指该计划一直没有能够处理它,调试器是第一位的。当你让它通过,应用程序将处理它很好,这样就不会出现错误。

在这种特殊情况下,事情是,XMLSerializer的可以使用在他们的编译架构信息集。因此,它会尝试加载以防万一它存在的组件。如果不是,这不是一个问题,但如果这样做,将使用它会更快。当您在释放模式编译你的项目,你经常会得到XMLSerializer的组件。

您应该建立Visual Studio中忽略抛出(第一次机会)例外,只有打破未处理的。

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?

解决方案

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.

这篇关于中的XMLSerializer的构造函数第一次机会异常发生的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆