Compiling interop dlls for SMTP sinks

Microsoft developmentBefore a few months ago I knew little of Microsoft Exchange. Now I know a moderate amount. Which is alot more than I'd ever want to know. The most interesting aspect of developing for Exchange is the abundance of not information about it - Look all over the internet and you will find tonnes of information not about Exchange.

This huge amount of not documentation, and not example code has shortened my life by many many years. At least a few of these years went in to attempting to follow the Microsoft knowledge base article Writing Managed Sinks for SMTP and Transport Events.

The rest of this article is for those who are currently suffering the same fate of an inability to compile the 2 dll files: Microsoft.Exchange.Transport.EventInterop.dll and Microsoft.Exchange.Transport.EventWrappers.dll

The article on writing managed code was going well, all the way up to point 2 - nmake.exe. After I found a copy of it somewhere, I run it in the ManagedSinksWP directory... it started out compiling the EventInterop ok, with a whole swag of messages like so:

Processing c:\Program Files\Microsoft Platform SDK\Include\mailmsg.idl
mailmsg.idl
Processing c:\Program Files\Microsoft Platform SDK\Include\oaidl.idl
oaidl.idl

But then trouble struck with a bunch of scary warnings like so:

TlbImp warning: At least one of the arguments for 'IMailMsgProperties.MapContent' can not be marshaled by the runtime marshaler. Such arguments will therefore be passed as a pointer and may require unsafe code to manipulate.
AND
TlbImp warning: The type library importer could not convert the signature for the member '_FIO_CONTEXT.m_hFile'.

And finaly bumming out with:

patching file '.\obj\Microsoft.Exchange.Transport.EventInterop.il.orig'
Hunk #5 FAILED at 1011.
Hunk #42 FAILED at 3619.
2 out of 42 hunks FAILED -- saving rejects to file '.\obj\Microsoft.Exchange.Transport.EventInterop.il.rej'
NMAKE : fatal error U1077: 'patch' : return code '0x1'
Stop.

It did create the EventInterop.dll file in the "obj" directory, but it looked fishy. After several hours (or was it days) of looking for files, programs, settings and directories I finally ended up with this setting:

  1. Installed the Windows Platform SDK (just the core stuff) - you can get the SDK from the Microsoft site... somewhere.
  2. Added environment settings: Make sure the environment variables had the Platform SDK and .Net paths for both the includes and the libraries.
  3. Added a path to tlbimp.exe in the environment variables - C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin and also to ilasm.exe which was in c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322

It ran like a charm. It filled me with joy. Here are the files, incase you give up on making your own:

EventInterop & EventWrappers