Hi,
Implementing a simple MVC in vb. The controller instance creates and holds instances of the model and view:
The View and Model classes' constructors look like as follows:
Within View and Model I have made calls to functions within the controller, eg:
The function performs actions on controller.myVi ew and controller.myMo del, however, I get an error saying myView is no longer instantiated:
"Object reference not set to an instance of an object."
So it looks like when I passed controller to the View ByRef, it actually just passed it as if ByVal, and the controller held by View is different to the controller which created and holds View.
Is that what is happening? Any ideas for a solution?
Implementing a simple MVC in vb. The controller instance creates and holds instances of the model and view:
Code:
Public Class Controller
Public Property myModel As Model
Public Property myView As View
Public Sub New()
Me.myModel = New Model(Me)
Me.myView = New View(Me)
End Sub
Code:
Public Class View
Dim controller As Controller
Public Sub New(ByRef ctrl As Controller)
Me.controller = ctrl
End Sub
Code:
Private Sub AddRangeButton_Click(...)
Me.controller.a_function()
"Object reference not set to an instance of an object."
So it looks like when I passed controller to the View ByRef, it actually just passed it as if ByVal, and the controller held by View is different to the controller which created and holds View.
Is that what is happening? Any ideas for a solution?
Comment