Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
NullReferenceException vb.net_.net_Vb.net_Nullreferenceexception - Fatal编程技术网

NullReferenceException vb.net

NullReferenceException vb.net,.net,vb.net,nullreferenceexception,.net,Vb.net,Nullreferenceexception,我收到一个错误,因为“对象引用未设置为对象的实例” 在代码的第三行。 可能的原因是什么 Dim table As New DataTable() Me.bindingSource1.DataSource = table Me.bindingSource1 = DataGridView1.DataSource table = Me.bindingSource1.DataSource 我只需要知道可能的原因要么“Me”为null(VB中没有),要么DataGridView1为null。原因可能在代

我收到一个错误,因为“对象引用未设置为对象的实例” 在代码的第三行。 可能的原因是什么

Dim table As New DataTable()
Me.bindingSource1.DataSource = table
Me.bindingSource1 = DataGridView1.DataSource
table = Me.bindingSource1.DataSource

我只需要知道可能的原因

要么“Me”为null(VB中没有),要么DataGridView1为null。原因可能在代码的其他地方。使用调试器查找。

可能
DataGridView1
可能是
nothing
Me
没有问题,因为执行跨越了第二行,没有任何中断。检查
DataGridView1
是否为空

  • 在第3行设置一个断点
  • 断点
    敲打时,按
    Ctrl+I
    (即时窗口)
  • 在其中键入
    ?DataGridView1
  • 然后按ENTER键,您将发现它是否为nothing