【发布时间】:2013-10-31 04:38:45
【问题描述】:
我正在尝试测试对象的实例,但 VB 吐出并抛出异常:
Conversion from string "" to type 'Boolean' is not valid.
这是我的测试方式:
Dim objGA As New Gatherer.Gathered("", -1)
objGA = objGatherers(idx)
If Not objGA Is Nothing Then <--exception occurs here
' Do something here
End If
如果我不做这个检查,我会得到:
Object reference not set to an instance of an object.
我不明白第一个错误,因为objGA 是对象而不是字符串!
我还应该如何执行此测试?有一致的检查方法吗?
【问题讨论】:
-
你能粘贴 objGatherers 方法代码吗?错误就在其中。
-
我不能,因为我无权访问源代码。
-
Gatherer.Gathered("", -1) 和 objGatherers(idx) 的返回类型是什么
-
您似乎没有发布发生错误的代码。请在您的问题中指出导致转换错误的行。
-
@CarlosLanderas 返回的对象是一个聚集的对象。 objGatherers 是一个数组。
标签: asp.net vb.net exception object-reference