C #Android未处理的异常错误System.NullReferenceException

时间:2017-05-18 12:01:42

标签: c# android sqlite xamarin unhandled-exception

我正在尝试将数据库数据插入列表视图

错误代码:

Unhandled Exception:

System.NullReferenceException: Object reference not set to an instance of an object. occurred

enter image description here

更新1: enter image description here

2 个答案:

答案 0 :(得分:1)

shMsg或sqldb为空。

答案 1 :(得分:1)

在第shMsg = FindViewById<TextView> (Resource.Id.shMsg);行放置一个断点然后检查您的资源是否已填满,如果您继续执行第1步,则变量shMsg是否有值。 然后继续步进,直到您意识到哪个对象具有null值。

您获得此异常的原因是因为您尝试获取某些不存在的属性,因为它是null

如果sqldb变量为null,请确保不要过早地丢弃与数据库的连接,这是一个常见的错误。

相关问题