Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Opening A Form using Reflection

Opening A Form using Reflection

Scheduled Pinned Locked Moved C#
helpquestion
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tristan Rhodes
    wrote on last edited by
    #1

    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

    L D A 3 Replies Last reply
    0
    • T Tristan Rhodes

      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

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      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

      T 1 Reply Last reply
      0
      • L leppie

        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

        T Offline
        T Offline
        Tristan Rhodes
        wrote on last edited by
        #3

        It's just a blank form, default constructor variables. Nothing added.

        L 1 Reply Last reply
        0
        • T Tristan Rhodes

          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

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          • T Tristan Rhodes

            It's just a blank form, default constructor variables. Nothing added.

            L Offline
            L Offline
            leppie
            wrote on last edited by
            #5

            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

            T 1 Reply Last reply
            0
            • L leppie

              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

              T Offline
              T Offline
              Tristan Rhodes
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              • T Tristan Rhodes

                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

                A Offline
                A Offline
                afinnell
                wrote on last edited by
                #7

                It appears in this context the 'Class' means that the form attempted to register a new 'Class' (Description of a window) with the Win32 API RegisterClass. I do think posting the code might help. - Drew

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups