By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,990 Members | 2,279 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,990 IT Pros & Developers. It's quick & easy.

object does not match target type reflection Error

P: n/a
I have the following code that sets some public properties in an EXE program
I load using LoadFrom. I set the property values and all was well. Then I
changed the loading program to remove a form and clean up some stuff and now
I get the error "Object Does Not Match Targe Type". What am I doing wrong.
I have included code from both the calling program and the class in the
called program that sets the properties. I can see the

Calling program.

Dim extAssembly As Assembly =
Assembly.LoadFrom("D:\testload\TestLoad\TestLoad\b in\Release\testload.exe")
Dim extForm As Form = extAssembly.CreateInstance("TestLoad.Form1", True)

Dim a As Type = extAssembly.GetType("TestLoad.Login")

TextBox1.Text &= a.ToString & vbCrLf

If a.Name.ToString = "Login" Then

Dim x() As PropertyInfo = a.GetProperties()

TextBox1.Text &= "Properties:" & vbCrLf

For i As Integer = 0 To UBound(x)

Select Case x(i).Name.ToString

Case "UserID"

TextBox1.Text &= "Name: " & x(i).Name.ToString & vbCrLf

x(i).SetValue(extForm, "WrightJW", Nothing) ----> Produces the Error

Case "UserType"

TextBox1.Text &= "Name: " & x(i).Name.ToString & vbCrLf

x(i).SetValue(extForm, "Admin", Nothing)

Case "Certification"

TextBox1.Text &= "Name: " & x(i).Name.ToString & vbCrLf

x(i).SetValue(extForm, "Certified", Nothing)

End Select

Next

End If

extForm.Name = "TestLoad"

extForm.Text = "TestLoad"

Me.AddOwnedForm(extForm)

extForm.Show()

Called Class
Public Class Login
Private strUserID As String

Private strUserType As String

Private strCertification As String

Public Property UserID() As String

Get

UserID = strUserID

End Get

Set(ByVal value As String)

strUserID = value

End Set

End Property

Public Property UserType() As String

Get

UserType = strUserType

End Get

Set(ByVal value As String)

strUserType = value

End Set

End Property

Public Property Certification() As String

Get

Certification = strCertification

End Get

Set(ByVal value As String)

strCertification = value

End Set

End Property
End Class

John
Apr 4 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.