I have created an application that will dynamically load other DLLs (plugins).
The new plugin is a winform with an embedded IE Browser.
I am wanting to have the form to run in its own thread. This would allow for other
plugins and the main application to be free to do other work. I have written a
little TestDriver for the plugin and am having some difficulty.
If I don't use threads everything works just fine. If I do use threads, upon finishing
the thread.Join() loop, I step to the end of main and I receive the same exception 3 times.
Any help would be appreciated.
Dave
Da**********@Be llsouth.net
=============== =============== =============== =============== =
An unhandled exception of type 'System.NullRef erenceException '
occurred in system.windows. forms.dll
Additional information: Object reference not set to an instance of an object.
=============== =============== =============== =============== =============== ===
[STAThread]
static void Main()
{
IPlugIn plugin = null;
Assembly assembly = null;
Object obj = null;
String s = null;
Thread thr = null;
try
{
assembly = Assembly.LoadFr om("..\\..\\..\ \bin\\Debug\\AJ B.dll");
Type[] types = assembly.GetExp ortedTypes( );
foreach (Type t in types )
{
Type interfaceT = t.GetInterface( "IPlugIn" );
if( null != interfaceT )
{
plugin = (IPlugIn)assemb ly.CreateInstan ce(t.ToString() );
obj = assembly.Create Instance(t.Full Name);
s = obj.GetType().T oString();
plugin.PluginID = 74;
thr = new Thread( new ThreadStart(plu gin.Execute) );
thr.ApartmentSt ate = ApartmentState. STA;
thr.IsBackgroun d = false;
thr.Start();
//plugin.Execute( );
}
}
}
catch (Exception e)
{
s = Application.Exe cutablePath.ToS tring() + "\n" + e.ToString() + e.Message + e.StackTrace;
MessageBox.Show (s, "ExecutePlugin( ) Error");
}
thr.Join();
}