G
Guest
Hi
I have a solution that has 2 windows forms projects: one a very simplistic
form, and the other a stub to do nothing more than launch the first's form.
I got the vb code and concept from
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadvnet/html/vbnet10142001.asp
Ive converted it to c#, and when I step it through the debugger, each line
looks good, returning data that looks valid; the catch never fires unless I
intentionally mess things up, like garble the path to the dll.
HOWEVER - the frmToShow.Show() seems to do nothing. The form doesnt
display, and the constructor doesnt seem to fire.
Help!
Thanks, Mark
[STAThread]
static void Main
{
try
{
// Application.Run(new Form1());
string asmLoadedPath=String.Empty;
asmLoadedPath=@"C:\sConsoleUI.dll";
Assembly asm;
Type asmFormType;
Object frmInstance;
Form frmToShow;
// access the assembly with the Form
asm = Assembly.LoadFrom(asmLoadedPath);
// pull the Form from the assembly
asmFormType=asm.GetType("ConsoleUI.frmMain");
// create an instance of the Form
frmInstance=Activator.CreateInstance(asmFormType);
// cast the instance to a Form
frmToShow=(Form)frmInstance;
// display the form
frmToShow.Show();
}
catch (Exception ex)
{
string errMsg=ex.Message;
MessageBox.Show(errMsg);
}
}
I have a solution that has 2 windows forms projects: one a very simplistic
form, and the other a stub to do nothing more than launch the first's form.
I got the vb code and concept from
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadvnet/html/vbnet10142001.asp
Ive converted it to c#, and when I step it through the debugger, each line
looks good, returning data that looks valid; the catch never fires unless I
intentionally mess things up, like garble the path to the dll.
HOWEVER - the frmToShow.Show() seems to do nothing. The form doesnt
display, and the constructor doesnt seem to fire.
Help!
Thanks, Mark
[STAThread]
static void Main
{
try
{
// Application.Run(new Form1());
string asmLoadedPath=String.Empty;
asmLoadedPath=@"C:\sConsoleUI.dll";
Assembly asm;
Type asmFormType;
Object frmInstance;
Form frmToShow;
// access the assembly with the Form
asm = Assembly.LoadFrom(asmLoadedPath);
// pull the Form from the assembly
asmFormType=asm.GetType("ConsoleUI.frmMain");
// create an instance of the Form
frmInstance=Activator.CreateInstance(asmFormType);
// cast the instance to a Form
frmToShow=(Form)frmInstance;
// display the form
frmToShow.Show();
}
catch (Exception ex)
{
string errMsg=ex.Message;
MessageBox.Show(errMsg);
}
}