【问题标题】:VB Web Service call error Object reference not setVB Web服务调用错误未设置对象引用
【发布时间】:2014-03-11 23:35:45
【问题描述】:

大家好,我想弄清楚为什么会出现以下错误:

Object reference not set to an instance of an object.

在代码的第 2 行:

1.  Dim HTPCws As HTPCWS.ServiceVB
2.  Dim returned As String = HTPCws.DisplayMessageVB(what2send)

当我知道 what2send 确实有发送价值时......

Web 服务代码是这样的:

<WebMethod()> Public Function DisplayMessageVB(ByVal beingSent As String) As String
    _strfromws = beingSent
    Return "DONE"
End Function

我会忘记什么?

【问题讨论】:

  • 您的参考文献中有 HTPCWS(带大写字母)吗?

标签: vb.net web-services rest


【解决方案1】:

HTPCws 尚未实例化。将代码更改为:

Dim HTPCws = New HTPCWS.ServiceVB()
Dim returned As String = HTPCws.DisplayMessageVB(what2send)

Dim HTPCws As HTPCWS.ServiceVB 声明了一个变量,但没有为它分配一个对象。命名也有点混乱。更好:

Dim service = New HTPCWS.ServiceVB()
Dim returned As String = service.DisplayMessageVB(what2send)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-08
    • 1970-01-01
    相关资源
    最近更新 更多