特定错误:“未将对象引用设置为对象的实例." [英] specific error on :"Object reference not set to an instance of an object."
问题描述
我从计算机模型中通过 X-Copying 制作了一个程序.通过单击一个按钮,它开始运行并且运行良好.但是当我再次单击该按钮(不关闭程序)时,它的运行过程完成后,它提示错误:未将对象引用设置为对象的实例."我在这里写了我 X-Copied Visual Studio 的子主要内容:
I've made a program by X-Copying from a computer model. By clicking a button it starts running and it goes so fine. But after its run process finished when I click that button again (without closing the program), it prompts the error :"Object reference not set to an instance of an object." I've written here the sub main that I X-Copied Visual studio:
Public Sub Main1(ByVal FileName As String)
AddHandler myModel.Init, AddressOf OnInitilize
AddHandler myModel.IterBottom, AddressOf OnIterationBottom
AddHandler myModel.IterTop, AddressOf OnIterationTop
AddHandler myModel.Converged, AddressOf OnIterationConverge
AddHandler myModel.End, AddressOf OnFinished
AddHandler myModel.OnMessage, AddressOf OnMessage
AddHandler myModel.OnModsimError, AddressOf OnMessage
XYFileReader.Read(myModel, FileName)
Dim myModsim As New Modsim
Csu.Modsim.NetworkUtils.ManageUnits.Unit_Conversion_Controller(myModel)
myModsim.RunSolver(myModel)
End Sub
错误发生在myModel"上!我不知道为什么它在第二次运行时引用为空!
The error happens for "myModel"! I don't know why it's null referenced in the second run!
推荐答案
decyclone 有一点.放置一个断点并逐行通过它.我还会查看 XYFileReader
对象.另一方面,大多数时候我看到这样的错误是因为我调用了另一个对象的函数,并且我对一个没有的对象做了一些事情.因此,还要检查 Unit_Conversion_Controller
内部.
decyclone has a point. Put a breakpoint and go thorugh it line by line. I would also look at the XYFileReader
object.
On the other hand, most of the time I see such error is because I call a function of another object and I do something with an object that is Nothing there. So, check inside Unit_Conversion_Controller
as well.
当您看到错误消息时,错误在哪一行?
When you see the error message, which line is the error on?
这篇关于特定错误:“未将对象引用设置为对象的实例."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!