Display form from string - 2nd post

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

    #1

    Display form from string - 2nd post

    want to be able to pass a formname as a string and have the form displayed.
    I have read about using the Type and Assembly or Activator .CreateInstance
    and have tried several things but none of it works. Here is my situation. I
    have a dll called BaseClasses and it has a class called BaseForm. I then
    have another dll called Test and a 3rd dll called Insured. When a button is
    pressed I want to have a method in the Test.dll call a method in the BaseForm
    that accepts the formname and then the BaseForm will display the form passed
    in, such as Insured.Insured Search (in Insured.dll). I try to get the
    assembly, but it never sees the Insured.Insured Search. The Insured.dll and
    Test.dll have reference to BaseClasses but BaseClasses doesn't reference the
    other dlls. Here is some code:


    BaseClasses.Nav igate(String formName)


    {
    Assembly aCurAssembly = Assembly.GetExe cutingAssembly( );
    CybeReBaseForm oform = aCurAssembly.Cr eateInstance(sF ormName,true);


    }


    Test.cmd_click( )

    {
    base.Navigate(" Insured.Insured Search");


    }


    Let me know if this doesn't make sense or if more info is needed.

    --
    Thanks,
    Leslie
  • Jon Skeet [C# MVP]

    #2
    Re: Display form from string - 2nd post

    Leslie <Leslie@discuss ions.microsoft. com> wrote:[color=blue]
    > want to be able to pass a formname as a string and have the form displayed.
    > I have read about using the Type and Assembly or Activator .CreateInstance
    > and have tried several things but none of it works. Here is my situation. I
    > have a dll called BaseClasses and it has a class called BaseForm. I then
    > have another dll called Test and a 3rd dll called Insured. When a button is
    > pressed I want to have a method in the Test.dll call a method in the BaseForm
    > that accepts the formname and then the BaseForm will display the form passed
    > in, such as Insured.Insured Search (in Insured.dll). I try to get the
    > assembly, but it never sees the Insured.Insured Search. The Insured.dll and
    > Test.dll have reference to BaseClasses but BaseClasses doesn't reference the
    > other dlls.[/color]

    Having references does basically nothing when it comes to reflection.
    You're still looking for the form name within the currently executing
    assembly, which probably *isn't* what you're after. It sounds like you
    actually want to use Insured.dll.

    --
    Jon Skeet - <skeet@pobox.co m>
    Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

    If replying to the group, please do not mail me too

    Comment

    • Leslie

      #3
      Re: Display form from string - 2nd post

      What is the solution... If what I am looking for is in the reference library
      and createinstance wont work? I am trying to keep each type of business in
      its own dll and avoid circular dependence when screens in different modules
      navigate to other screens.

      Thanks,
      Leslie

      "Jon Skeet [C# MVP]" wrote:
      [color=blue]
      > Leslie <Leslie@discuss ions.microsoft. com> wrote:[color=green]
      > > want to be able to pass a formname as a string and have the form displayed.
      > > I have read about using the Type and Assembly or Activator .CreateInstance
      > > and have tried several things but none of it works. Here is my situation. I
      > > have a dll called BaseClasses and it has a class called BaseForm. I then
      > > have another dll called Test and a 3rd dll called Insured. When a button is
      > > pressed I want to have a method in the Test.dll call a method in the BaseForm
      > > that accepts the formname and then the BaseForm will display the form passed
      > > in, such as Insured.Insured Search (in Insured.dll). I try to get the
      > > assembly, but it never sees the Insured.Insured Search. The Insured.dll and
      > > Test.dll have reference to BaseClasses but BaseClasses doesn't reference the
      > > other dlls.[/color]
      >
      > Having references does basically nothing when it comes to reflection.
      > You're still looking for the form name within the currently executing
      > assembly, which probably *isn't* what you're after. It sounds like you
      > actually want to use Insured.dll.
      >
      > --
      > Jon Skeet - <skeet@pobox.co m>
      > http://www.pobox.com/~skeet
      > If replying to the group, please do not mail me too
      >[/color]

      Comment

      • Jon Skeet [C# MVP]

        #4
        Re: Display form from string - 2nd post

        Leslie <Leslie@discuss ions.microsoft. com> wrote:[color=blue]
        > What is the solution... If what I am looking for is in the reference library
        > and createinstance wont work? I am trying to keep each type of business in
        > its own dll and avoid circular dependence when screens in different modules
        > navigate to other screens.[/color]

        You need *something* to know which assembly to look in. You could pass
        that information in, or BaseClasses could know it, but something
        certainly has to.

        --
        Jon Skeet - <skeet@pobox.co m>
        Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

        If replying to the group, please do not mail me too

        Comment

        • Leslie

          #5
          Re: Display form from string - 2nd post

          I have searched to find out how to pass the assembly information and can't
          find anything. Can you point me to another thread that addresses this issue
          or let me know how this can be done?

          Thanks

          "Jon Skeet [C# MVP]" wrote:
          [color=blue]
          > Leslie <Leslie@discuss ions.microsoft. com> wrote:[color=green]
          > > What is the solution... If what I am looking for is in the reference library
          > > and createinstance wont work? I am trying to keep each type of business in
          > > its own dll and avoid circular dependence when screens in different modules
          > > navigate to other screens.[/color]
          >
          > You need *something* to know which assembly to look in. You could pass
          > that information in, or BaseClasses could know it, but something
          > certainly has to.
          >
          > --
          > Jon Skeet - <skeet@pobox.co m>
          > http://www.pobox.com/~skeet
          > If replying to the group, please do not mail me too
          >[/color]

          Comment

          • Jon Skeet [C# MVP]

            #6
            Re: Display form from string - 2nd post

            Leslie <Leslie@discuss ions.microsoft. com> wrote:[color=blue]
            > I have searched to find out how to pass the assembly information and can't
            > find anything. Can you point me to another thread that addresses this issue
            > or let me know how this can be done?[/color]

            Well, you could either pass the name of the assembly, or if you know a
            type in it, you could just do typeof(Foo).Ass embly.

            --
            Jon Skeet - <skeet@pobox.co m>
            Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

            If replying to the group, please do not mail me too

            Comment

            Working...