Infosys Microsoft Alliance and Solutions blog

« Windows Workflow Foundation Web Workflow Approvals Starter Kit – A Review | Main | WPF - Finding Control Location »

Handling AppDomain's AssemblyLoad Event

In my earlier blog I had discussed about creating a new AppDomain. You may have a need to track the loading of assemblies in this newly created AppDomain. AppDomain class provides an event for this purpose called AssemblyLoad. However when I tried to work with it, I never got the event to fire up.

The catch is that the event handler needs to be static. When I had added the event handler via VS 2005 by using the tip that appears once you type "+=" after an event, it added the event handler as private void and missed the "static" qualifier. Due to this the event handler was not getting called. Once I added this, it started to work like a breeze. The handler signature will look something like the following

        static void domain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)

        {

            //add code to handle assembly load event here

        }

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

Please key in the two words you see in the box to validate your identity as an authentic user and reduce spam.

Subscribe to this blog's feed

Follow us on

Blogger Profiles

Infosys on Twitter