I'd like to use Activator.CreateInstance with a non-public constructor for a class of mine. Here's my code:
but in spite of the use of the NonPublivc flag, I get the message that the constructor is not found. Maybe I need to set the binder parameter to something, but I've no idea what. Anyone know how to go about this?
Code:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Activator.CreateInstance(GetType(X1), Reflection.BindingFlags.NonPublic, Nothing, New Object() {8})
Dim j As New X1(8)
End Sub
End Class
Public Class X1
Friend Sub New(ByVal p As Long)
MsgBox(p)
End Sub
End Class
but in spite of the use of the NonPublivc flag, I get the message that the constructor is not found. Maybe I need to set the binder parameter to something, but I've no idea what. Anyone know how to go about this?