Display form from string - 2nd post

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.InsuredSearch (in Insured.dll). I try to get the
assembly, but it never sees the Insured.InsuredSearch. The Insured.dll and
Test.dll have reference to BaseClasses but BaseClasses doesn't reference the
other dlls. Here is some code:


BaseClasses.Navigate(String formName)


{
Assembly aCurAssembly = Assembly.GetExecutingAssembly();
CybeReBaseForm oform = aCurAssembly.CreateInstance(sFormName,true);


}


Test.cmd_click()

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


}


Let me know if this doesn't make sense or if more info is needed.
 
Leslie said:
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.InsuredSearch (in Insured.dll). I try to get the
assembly, but it never sees the Insured.InsuredSearch. The Insured.dll and
Test.dll have reference to BaseClasses but BaseClasses doesn't reference the
other dlls.

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.
 
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
 
Leslie said:
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.

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.
 
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
 
Leslie said:
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?

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