如何解决First Chance异常错误 [英] How to solve First Chance exception Error

查看:169
本文介绍了如何解决First Chance异常错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



这是我第二周尝试解决此错误而且我几乎放弃了,希望你们能够提供帮助。 />


我一直收到这个错误:



*发生了'System.NullReferenceException'类型的第一次机会异常EntityFramework.dll



附加信息:对象引用未设置为对象的实例。*





我有一个WCF项目,我从sql server查询数据。所以基本上我有一个检索数据库的方法。问题是当我运行我的项目时,项目将成功检索数据库中的某些记录。当用于搜索不同的记录(通过Id)时,同样的方法会产生异常错误处理。我不知道为什么它适用于某些记录,并且在搜索时不适用于其他记录:( ..我的项目是非常大,我不知道你们想在这里显示什么代码块但是随意。

Hello All,

This is my second week trying to resolve this error and i am almost giving up , hopefully you guys will be able to assist.

I keep getting this error:

*A first chance exception of type 'System.NullReferenceException' occurred in EntityFramework.dll

Additional information: Object reference not set to an instance of an object.*


I have got a WCF project in which I am querying data from sql server. So basically i have got a method that is retrieving the database. The problem is that when i run my project, the project will successfully retrieve SOME records form database. The same method when used to search for a different record (by Id) gives an exception error handling .. I don't know why it works for certain records and doesn't work for other records when searched :( .. my project is pretty big and I wouldn't know what block of code you guys would like to show on here but feel free to.

推荐答案

它对一些记录不起作用因为记录中的某些东西不在那里。空引用意味着你想要访问的东西不在那里。



你需要获得一个完整的堆栈跟踪,这样你就可以看到它是什么代码行,或者你只需​​要调试它并弄清楚它。



因为我们看不到你的代码所以无法知道它是什么具体是。
It doesn't work for some records because something in the record is not there. Null reference means whatever you are trying to access is not there.

You need to get a full stack trace so you can see what line of code it is or you just need to debug it and figure it out.

Since we can't see your code there is no way of knowing what it is specifically.


你通常不需要担心第一次机会异常。它们只是表明你正在调用的代码抛出了一个很可能被捕获的异常和h orled。



如果代码没有处理异常,你将获得第二次机会异常,此时调试器将显示未处理的异常消息。



http://blogs.msdn.com/b/davidklinems/archive/2005/07/12/438061.aspx [ ^ ]
You usually don't need to worry about first chance exceptions. They're just an indication that the code you're calling has thrown an exception which will most likely be caught and handled.

If the code doesn't handle the exception, you'll get a second chance exception, at which point the debugger will display the "unhandled exception" message.

http://blogs.msdn.com/b/davidklinems/archive/2005/07/12/438061.aspx[^]


这篇关于如何解决First Chance异常错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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