MDI problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bevo

    #1

    MDI problem

    I use reflection to invoke a class derived from
    System.Windows, Forms.Form and I want this form to run as
    an MDIChild.

    When I run it as a non-MDIChild the world smiles, when I
    run it as a MDIChild its Show-method gives me this
    exception:

    'An unhandled exception of
    type 'System.Missing MethodException ' occurred in
    mscorlib.dll

    Additional information: No parameterless constructor
    defined for this object.'

    Has anyone experienced something like this? (the form
    class has one constructor and it has no parameters)

    Bevo
  • Morten Wennevik

    #2
    Re: MDI problem

    Not really, but have you made sure you have set the MDIParent-property of
    the child before calling Show();

    --
    Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

    Comment

    • Nicholas Paldino [.NET/C# MVP]

      #3
      Re: MDI problem

      Bevo,

      Can you give an example of how you are using Reflection to call the form
      you want to use as an MDI child? Are you setting the IsMdiChild property on
      the form to true before you add it to the MDI client?

      Hope this helps.


      --
      - Nicholas Paldino [.NET/C# MVP]
      - nicholas.paldin o@exisconsultin g.com

      "Bevo" <bergsvein.voll an@shipnet.no> wrote in message
      news:054b01c376 d0$f0fc2f40$a00 1280a@phx.gbl.. .[color=blue]
      > I use reflection to invoke a class derived from
      > System.Windows, Forms.Form and I want this form to run as
      > an MDIChild.
      >
      > When I run it as a non-MDIChild the world smiles, when I
      > run it as a MDIChild its Show-method gives me this
      > exception:
      >
      > 'An unhandled exception of
      > type 'System.Missing MethodException ' occurred in
      > mscorlib.dll
      >
      > Additional information: No parameterless constructor
      > defined for this object.'
      >
      > Has anyone experienced something like this? (the form
      > class has one constructor and it has no parameters)
      >
      > Bevo[/color]


      Comment

      • Bergsvein Vollan

        #4
        Re: MDI problem

        Nicholas
        My code goes like this (inside my MDIParent):

        Assembly Host = Assembly.Load(< assemblyname>);
        Form MyWindow = (Form)Host.Crea teInstance(<cla ssname>);
        MyWindow.MdiPar ent = this;
        MyWindow.Show() ;

        No, I have not set the IsMDIChild property on MyWindow, it is a readonly
        property as far as I can tell. Isnt the statement 'MyWindow.MdiPa rent =
        this'
        supposed to achieve the same relation?


        Bevo

        *** Sent via Developersdex http://www.developersdex.com ***
        Don't just participate in USENET...get rewarded for it!

        Comment

        • Bevo

          #5
          Re: MDI problem

          Nicholas
          My code goes like this (inside my MDIParent):

          Assembly Host = Assembly.Load(< assemblyname>);
          Form MyWindow = (Form)Host.Crea teInstance(<cla ssname>);
          MyWindow.MdiPar ent = this;
          MyWindow.Show() ;

          No, I have not set the IsMDIChild property on MyWindow,
          it is a readonly property as far as I can tell. Isnt the
          statement 'MyWindow.MdiPa rent = this'
          supposed to achieve the same relation?


          Bevo


          [color=blue]
          >-----Original Message-----
          >Bevo,
          >
          > Can you give an example of how you are using[/color]
          Reflection to call the form[color=blue]
          >you want to use as an MDI child? Are you setting the[/color]
          IsMdiChild property on[color=blue]
          >the form to true before you add it to the MDI client?
          >
          > Hope this helps.
          >
          >
          >--
          > - Nicholas Paldino [.NET/C# MVP]
          > - nicholas.paldin o@exisconsultin g.com
          >
          >"Bevo" <bergsvein.voll an@shipnet.no> wrote in message
          >news:054b01c37 6d0$f0fc2f40$a0 01280a@phx.gbl. ..[color=green]
          >> I use reflection to invoke a class derived from
          >> System.Windows, Forms.Form and I want this form to run[/color][/color]
          as[color=blue][color=green]
          >> an MDIChild.
          >>
          >> When I run it as a non-MDIChild the world smiles, when[/color][/color]
          I[color=blue][color=green]
          >> run it as a MDIChild its Show-method gives me this
          >> exception:
          >>
          >> 'An unhandled exception of
          >> type 'System.Missing MethodException ' occurred in
          >> mscorlib.dll
          >>
          >> Additional information: No parameterless constructor
          >> defined for this object.'
          >>
          >> Has anyone experienced something like this? (the form
          >> class has one constructor and it has no parameters)
          >>
          >> Bevo[/color]
          >
          >
          >.
          >[/color]

          Comment

          Working...