InfiniTec - Henning Krauses Blog

Don't adjust your mind - it's reality that is malfunctioning

Building managed event sinks


  • 2008-04-11
    • Added information for EventSinks on Windows 2000
  • 2007-09-13
    • Revised the last section and clarified necessary permissions to run the event sink
    • Added links to related articles

More Information

On MSDN , there is an article describing describes the necessary steps to create an event sink with managed code (Building Managed Event Sink DLLs), and another one (Managing Event Registrations) explains how to register the eventsink on the target server. Unfortunately, that article does not explain how to deploy the event sink into production. The part where the COM+ application is created is simply missing. Additionally, the example misses one attribute that should be added to the assemblyinfo.cs (or assemblyinfo.vb).

The necessary attributes

Apart from the AssemblyKeyName or AssemblyKeyFileAttribute, you should add these attributes to the assemblyinfo.* file:

    1 [assembly: ApplicationActivation(ActivationOption.Server)]

    2 [assembly: ApplicationName("Title of COM+ Application")]

    3 [assembly: ApplicationAccessControl(false ,AccessChecksLevel = AccessChecksLevelOption.Application)]

Be sure to insert the correct name of the COM+ application in line 2.

Installing the COM+ application on a production server

Once you've copied all the assemblies into a folder on the destination server, you can use the Regvcs tool to register the eventsink assembly and create the COM+ application (Note: The above link points to the .NET 2.0 documentation. But the tool is also available for .NET 1.x). 

Just call

    1 regsvcs -fc managedeventsink.dll

The only thing left to do is to set the process identity for the newly created COM+ application. To do this, open the Component Services MMC (Under administrative tools) and navigate to your COM+ application. Open the properties of the application and select the identity tab. This looks like this:

Here you should select "This user" and enter a user account which has access to the folder to which the event sink will be bound. If you are writing a global event sink which is bound to a mailbox store, and want to access items outside of the scope from the thread on which the OnSyncSave method is called, that account must have permissions to access all mailboxes on that store. See How to grant access to all mailboxes on a mailbox store to a special account for more information on how to do this.

The event sink can now be registered on the Exchange server as described in the second article mentioned at the beginning of this article (See this article if you want to install the sink on Exchange 2007 64bit)

If you want to use an application settings file, you shoud read this article.

Considerations for Windows 2000

If you need to register your event sink on Windows 2000 you will run in a few problems because the COM+ version available. There are two main issues on this platform:

  • Loading of dependent assemblies - Windows 2000 will look for dependent assemblies of the eventsink in the working directory - which is %SystemRoot%\system32. To get around this issue, install all assemblies in the Global Assembly Cache.
  • Accessing configuration data - On Windows 2003 you can access an application.config by creating a manifest file and setting some COM+ options (See How to use applications settings from an event sink). Unfortunately, the required options are not available on Windows 2000. You'll have to put your configuration settings into the file %SystemRoot%\System32\dllhost.exe.config. The file will most likely not exists, so you'll have to create it.

Posted by Henning Krause on Thursday, April 13, 2006 12:00 AM, last modified on Friday, April 11, 2008 12:00 PM
Permalink | Post RSSRSS comment feed

Comments (1) -

On 5/19/2008 9:32:19 PM KD United States wrote:


Nice article but links does not work