I am loading a console application assembly from a resource into a memory stream (later to byte array) and executing the assembly in a new thread. Note that the container assembly is standard Winforms.
The console application is running in the new thread, but it is not visible. If the console application is replaced with winforms assembly, the main form is visible and works correctly. If I run the console application from disk as a test, it loads fine and is visible.
Any ideas?
ThreadStart _thdInvoke;
Thread _thdMain;
MethodInfo _methodInfo;
snip
/* memoryStream is the console application loaded from embedded resource */
var assembly = Assembly.Load(memoryStream.ToArray());
_methodInfo = assembly.EntryPoint;
_thdInvoke = InitializeEp;
_thdMain = new Thread(_thdInvoke);
_thdMain.Start();
snip
private void InitializeEp()
{
try
{
_methodInfo.Invoke(null, null);
}
catch (Exception)
{
}
}
Note that the console application Main method has been changed so that string[] args
has been removed.
Thanks for the help!