D
David Elliott
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
(e-mail address removed)
=============================================================
An unhandled exception of type 'System.NullReferenceException'
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.LoadFrom("..\\..\\..\\bin\\Debug\\AJB.dll");
Type[] types = assembly.GetExportedTypes( );
foreach (Type t in types )
{
Type interfaceT = t.GetInterface( "IPlugIn" );
if( null != interfaceT )
{
plugin = (IPlugIn)assembly.CreateInstance(t.ToString());
obj = assembly.CreateInstance(t.FullName);
s = obj.GetType().ToString();
plugin.PluginID = 74;
thr = new Thread( new ThreadStart(plugin.Execute) );
thr.ApartmentState = ApartmentState.STA;
thr.IsBackground = false;
thr.Start();
//plugin.Execute();
}
}
}
catch (Exception e)
{
s = Application.ExecutablePath.ToString() + "\n" + e.ToString() + e.Message + e.StackTrace;
MessageBox.Show(s, "ExecutePlugin() Error");
}
thr.Join();
}
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
(e-mail address removed)
=============================================================
An unhandled exception of type 'System.NullReferenceException'
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.LoadFrom("..\\..\\..\\bin\\Debug\\AJB.dll");
Type[] types = assembly.GetExportedTypes( );
foreach (Type t in types )
{
Type interfaceT = t.GetInterface( "IPlugIn" );
if( null != interfaceT )
{
plugin = (IPlugIn)assembly.CreateInstance(t.ToString());
obj = assembly.CreateInstance(t.FullName);
s = obj.GetType().ToString();
plugin.PluginID = 74;
thr = new Thread( new ThreadStart(plugin.Execute) );
thr.ApartmentState = ApartmentState.STA;
thr.IsBackground = false;
thr.Start();
//plugin.Execute();
}
}
}
catch (Exception e)
{
s = Application.ExecutablePath.ToString() + "\n" + e.ToString() + e.Message + e.StackTrace;
MessageBox.Show(s, "ExecutePlugin() Error");
}
thr.Join();
}