When you call ExecuteAssembly, the call returns when your OpenOutlook.exe
Main function returns, that is when you have done in your Main function, so
there is no need for an event, just unload the AD when the call returns.
Don't forget that your OpenOutlook.exe Main function runs on the callers
thread, so you probably want to create an auxiliary thread to run this code,
and because you are using COM interop in that assembly you'll have to
initialize the thread to enter a STA before starting.
Thread t = new...
t.ApartmentState= ApartmentState.STA;
t.Start();
Note also that you might want to change the assembly type from an exe into a
DLL and use CreateInstanceAndUnwrap to load a type in an auxiliary AD.
Willy.
"Max" <ma******@yahoo.com> wrote in message
news:O6*************@TK2MSFTNGP09.phx.gbl...
I didn't really mean to say unload assembly but rather just unload the
whole application domain. You see I got this library that opens
Outlook.exe and does some work, and when the user closes Outlook, the
library marshals all the objects and shutsdown the server (outlook.exe). I
would also like to unload the whole application domain as well just to
make sure everything is killed, so I would have something like this:
System.AppDomain newDomain =
System.AppDomain.CreateDomain("OutlookApplicationD omain");
newDomain.ExecuteAssembly(@"c:\OpenOutlook.exe");
But since outlook is controlled by the user I need some event to get back
to the main application before I unload the domain:
System.AppDomain.Unload(newDomain);
Any idea how to do this?
Cheers,
Max
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl... Hi,
You load the assembly using Assembly.Load*
AFAIK there is no method to unload an assembly. Why you want to do this?
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Max" <ma******@yahoo.com> wrote in message
news:et**************@TK2MSFTNGP12.phx.gbl... Hi,
I would like to be able to load an assembly file at runtime which will
do some work. When the work is done
I would like the main application to be informed so that the assembly
can be unloaded. How can I do this using
delegates and events?