Opening A Form using Reflection
-
I've written a little program that creates a form using reflection, however, when I attempt to show this form, it throws an error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ComponentModel.Win32Exception: Class already exists at System.Windows.Forms.WindowClass.RegisterClass() at System.Windows.Forms.WindowClass..ctor(String className, Int32 classStyle) at System.Windows.Forms.WindowClass.Create(String className, Int32 classStyle) at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp) at System.Windows.Forms.Control.CreateHandle() at System.Windows.Forms.Form.CreateHandle() at System.Windows.Forms.Control.get_Handle() at System.Windows.Forms.Control.SetVisibleCore(Boolean value) at System.Windows.Forms.Form.SetVisibleCore(Boolean value) at System.Windows.Forms.Control.set_Visible(Boolean value) at System.Windows.Forms.Control.Show() the only other form that exists is my primary application form. Does anyone know what causes this? Cheers Cata
-
I've written a little program that creates a form using reflection, however, when I attempt to show this form, it throws an error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ComponentModel.Win32Exception: Class already exists at System.Windows.Forms.WindowClass.RegisterClass() at System.Windows.Forms.WindowClass..ctor(String className, Int32 classStyle) at System.Windows.Forms.WindowClass.Create(String className, Int32 classStyle) at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp) at System.Windows.Forms.Control.CreateHandle() at System.Windows.Forms.Form.CreateHandle() at System.Windows.Forms.Control.get_Handle() at System.Windows.Forms.Control.SetVisibleCore(Boolean value) at System.Windows.Forms.Form.SetVisibleCore(Boolean value) at System.Windows.Forms.Control.set_Visible(Boolean value) at System.Windows.Forms.Control.Show() the only other form that exists is my primary application form. Does anyone know what causes this? Cheers Cata
Did you add the control to the Form? Is the bounds/size/visible set correctly? xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots
-
Did you add the control to the Form? Is the bounds/size/visible set correctly? xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots
It's just a blank form, default constructor variables. Nothing added.
-
I've written a little program that creates a form using reflection, however, when I attempt to show this form, it throws an error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ComponentModel.Win32Exception: Class already exists at System.Windows.Forms.WindowClass.RegisterClass() at System.Windows.Forms.WindowClass..ctor(String className, Int32 classStyle) at System.Windows.Forms.WindowClass.Create(String className, Int32 classStyle) at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp) at System.Windows.Forms.Control.CreateHandle() at System.Windows.Forms.Form.CreateHandle() at System.Windows.Forms.Control.get_Handle() at System.Windows.Forms.Control.SetVisibleCore(Boolean value) at System.Windows.Forms.Form.SetVisibleCore(Boolean value) at System.Windows.Forms.Control.set_Visible(Boolean value) at System.Windows.Forms.Control.Show() the only other form that exists is my primary application form. Does anyone know what causes this? Cheers Cata
Try posting the code your using to do this. We can't tell what you did from the Exception, but the Exception message does help. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
It's just a blank form, default constructor variables. Nothing added.
Well thats what Im asking you! If you dont add a control to the Form it will never show. You dont need to call show on it. Just add it. xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots
-
Well thats what Im asking you! If you dont add a control to the Form it will never show. You dont need to call show on it. Just add it. xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots
Sorry, i think i made a slight mistake. I was trying to construct a base form. Rather than an inherited one. It caused problems. Will make sure i don't try that again :) Cata
-
I've written a little program that creates a form using reflection, however, when I attempt to show this form, it throws an error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ComponentModel.Win32Exception: Class already exists at System.Windows.Forms.WindowClass.RegisterClass() at System.Windows.Forms.WindowClass..ctor(String className, Int32 classStyle) at System.Windows.Forms.WindowClass.Create(String className, Int32 classStyle) at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp) at System.Windows.Forms.Control.CreateHandle() at System.Windows.Forms.Form.CreateHandle() at System.Windows.Forms.Control.get_Handle() at System.Windows.Forms.Control.SetVisibleCore(Boolean value) at System.Windows.Forms.Form.SetVisibleCore(Boolean value) at System.Windows.Forms.Control.set_Visible(Boolean value) at System.Windows.Forms.Control.Show() the only other form that exists is my primary application form. Does anyone know what causes this? Cheers Cata