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
The error happens for "myModel"! I don't know why it's null referenced in the second run!
 
     
    