G
Guest
I am moving over to C# from VB.NET and am having some problems replicating
functionality that I could do in VB.NET.
In VB.NET I used to use the code
Dim frm As Object
Dim frmType As Type
Dim SampleAssembly As [Assembly]
SampleAssembly = [Assembly].Load(strLibrary)
frmType = SampleAssembly.GetType(strLibrary & "." & strClass)
frm = Activator.CreateInstance(frmType)
frmType.InvokeMember("Show", BindingFlags.InvokeMethod, Nothing, frm, Nothing)
This would show a form (strClass) that existed in a dll library
(strLibrary), so long as the library was in the same folder as the
application. The key point was that the library was NOT included as a
referenced library in the application project - this is because I am using
the method in a generic menu system.
My question is that in C# when I use the code
object frm;
Type frmType;
Assembly SampleAssembly;
SampleAssembly = Assembly.Load(strLibrary);
frmType = SampleAssembly.GetType(strLibrary + "." + strClass);
frm = Activator.CreateInstance(frmType);
frmType.InvokeMember("Show",BindingFlags.InvokeMethod,null,frm,null);
which I thought would do the same thing I find that it does not work unless
the strLibrary file is referenced into the application.....
What am I doing wrong in the C# code - how can I change it so that I DONT
have to reference in the library that contains the form I Want to run
Thanks all for you help in advance
functionality that I could do in VB.NET.
In VB.NET I used to use the code
Dim frm As Object
Dim frmType As Type
Dim SampleAssembly As [Assembly]
SampleAssembly = [Assembly].Load(strLibrary)
frmType = SampleAssembly.GetType(strLibrary & "." & strClass)
frm = Activator.CreateInstance(frmType)
frmType.InvokeMember("Show", BindingFlags.InvokeMethod, Nothing, frm, Nothing)
This would show a form (strClass) that existed in a dll library
(strLibrary), so long as the library was in the same folder as the
application. The key point was that the library was NOT included as a
referenced library in the application project - this is because I am using
the method in a generic menu system.
My question is that in C# when I use the code
object frm;
Type frmType;
Assembly SampleAssembly;
SampleAssembly = Assembly.Load(strLibrary);
frmType = SampleAssembly.GetType(strLibrary + "." + strClass);
frm = Activator.CreateInstance(frmType);
frmType.InvokeMember("Show",BindingFlags.InvokeMethod,null,frm,null);
which I thought would do the same thing I find that it does not work unless
the strLibrary file is referenced into the application.....
What am I doing wrong in the C# code - how can I change it so that I DONT
have to reference in the library that contains the form I Want to run
Thanks all for you help in advance