Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / April 2006

Tip: Looking for answers? Try searching our database.

TargetException: Object does not match target type.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Wright - 04 Apr 2006 22:13 GMT
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\bin\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
John Wright - 05 Apr 2006 17:37 GMT
Nevermind, I found the problem.

john
>I have the following code that sets some public properties in an EXE
>program
[quoted text clipped - 118 lines]
>
> John

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.