Repost: AppDomain.ExecuteAssembly: want notification when executing assembly starts

  • Thread starter Thread starter Gregg Walker
  • Start date Start date
G

Gregg Walker

Hi all,

Does anyone know howto receive a notification (event) when the assembly loaded by AppDomain.ExecuteAssembly loads the startup method
and begins executing it?

I want to give the user a visual (hour glass, etc.) that an application is being loaded while AppDomain.ExecuteAssembly is loading
assemblies. Once it begins executing the loaded assembly I want to make the visual go away. I'm using no touch deployment of
windows forms apps that are hosted on a Win2003 Server. I have a shell launcher app that calls ExecuteAssembly on the exe assembly
at the specified URL.

I tried using AppDomain.AssemblyLoad event but it fires every time each referenced assembly in the exe is loaded and I have no way
of knowing when the assembly actually begins executing.

As it stands now every time the launcher shell is started I get an AppStarting cursor until it is running (usually only takes a
second or less) but the cursor disappears from there on until the windows form app is actually up and running. This may take much
longer than a second or two because of network delays and assembly sizes. End result is the user thinks that nothing is happening
and tries to start the launcher shell again.

Thanks for any help.

Sincerely,
Gregg Walker
 
Hi Gregg,

AssemblyLoad event will be fired when an assembly is loaded, including the
actual exe and referenced assemblies. However, we can get the loaded
assembly's detail information from its parameter.For example:

Sub MyAssemblyLoadEventHandler(sender As Object, args As
AssemblyLoadEventArgs)
Console.WriteLine("ASSEMBLY LOADED: " + args.LoadedAssembly.FullName)
Console.WriteLine()
End Sub 'MyAssemblyLoadEventHandler

We can validate the assembly from .LoadedAssembly.

Hope this help,

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Hi Luke,

Thanks for the response.
We can validate the assembly from .LoadedAssembly.

I'm not sure I'm understanding how this can help me determine when the exe entry point begins executing after it is loaded. Am I
missing something?

I've already got an AssemblyLoadEventHandler and I can see the assemblies being loaded. I'm not sure however when the exe's entry
point is being executed.

Thanks,
Gregg Walker
 
Hi Greg,

We can get the loaded assembly's detail information from
MyAssemblyLoadEventHandler's parameter.For example:

Sub MyAssemblyLoadEventHandler(sender As Object, args As
AssemblyLoadEventArgs)
Console.WriteLine("ASSEMBLY LOADED: " + args.LoadedAssembly.FullName)
Console.WriteLine()
End Sub 'MyAssemblyLoadEventHandler

When the "args.LoadedAssembly.FullName" is exactly your exe app's name, we
can know it is being loaded.


Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Hi Luke,
When the "args.LoadedAssembly.FullName" is exactly your exe app's name, we
can know it is being loaded.

That's great! I believe that's what I'm looking for. I'll check it out and let you know if it does what I'm wanting.

Thanks much.
Gregg Walker
 
Back
Top