Creating an Instance of a Form From a String


Author
Message
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
By the way, if I change the code to this:



(Activator.CreateInstance(Type.GetType("Aspire.Sales.CustomerInvoices")) as Form).Show();




I get the following error:



Value cannot be null.\rParameter name: type




Obviously, the Type.GetType() function is not returning any type. I have confirmed the string. And, I have used several variations. No dice.



I started working on this yesterday afternoon. I am stumped. I had hoped a good night's sleep would provide a better perspective, but, alas!, it has not.



Bill

Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
This is turning out to be a little more difficult than I expected. I used the forum entry to guide me but I have run into a problem with the following code:



((Form)Activator.CreateInstance(mFormName, "Form")).Show();




The error that I get when I build the project is:



Cannot convert type 'System.Runtime.Remoting.ObjectHandle' to 'System.Windows.Forms.Form'




I have tried simply passing the string of the form ("MyNamespace.MyForm") to CreateInstance, but that does not work, either.



Any direction that you can provide would be helpful.

Bill
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search