我目前正在使用Visual Basic创建一个天气应用程序,该应用程序向openweathermap.org发出API调用以获取当前天气。当我将其作为Windows窗体应用程序进行测试时,它工作得很好,但是当我将其合并到DLL中时,出现了一个错误,即对象引用没有设置为对象的实例,代码如下:
Dim request as httpwebrequest= net.Webrequest.create("api.openweathermap.org/data/2.5/weather?q=delhi,in&mode=xml&appid=")
Dim response as net.webresponse=request.getresponse()
Dim stream as IO. Stream=response.getresponsestream()
Dim xmldoc as new xmldocument
Xmldoc.Load(stream)
错误出现在
行中Xmldoc.Load(stream)
它表示对象引用未设置为对象的实例。同样的声明在Windows窗体应用程序中运行得很完美。