Friday, October 24, 2008

Migrate my managed Event Sink from Exchange 2003 32bits to Exchange 2007 64bits

1) Get all 64 bit versions of the dependency files. From the Exchange 2007 64 bits server get:

- C:\Program Files\Microsoft\Exchange Server\Bin\Interop.msado28.dll
- C:\Program Files\Microsoft\Exchange Server\Bin\Interop.CDOEX.dll
- C:\Program Files\Microsoft\Exchange Server\Bin\exoledb.dll

2) Install the Exchange SDK and get C:\Program Files\Microsoft\Exchange Server 2007 SP1 SDK\August 2008\Libraries\Oledb\amd64\exevtsnk.tlb.

3) Create interop files for exoledb.dll and exevtsnk.tlb:

a.1) sn.exe -k exoledb.snk
a.2) tlbimp.exe exoledb.dll /keyfile: exoledb.snk /out: Interop.Exoledb.dll /machine:x64
b.1) sn.exe -k exevtsnk.snk
b.2) tlbimp.exe exevtsnk.tlb /keyfile: exevtsnk.snk /out: Interop.Exevtsnk.dll /machine:x64

4) Modify your Visual Studio project settings:

a.1) Go to Build -> Configuration Manager menu.
a.2) Under "Active solution platform", select "New...", then select x64 and in "Copy Settings From" select "Any CPU".
b.1) Click right button over your project, and then select Properties.
b.2) On "Application" left tab, select "Assembly Information" and check "Make COM-Visible".
b.3) On "Build" left tab, select x64 as "Platform target" and uncheck "Register for COM interop". Press "Advanced" button and check "Do not reference to mscorlib.dll".

5) Add references to your interop files (Interop.msado28.dll, Interop.CDOEX.dll, Interop.Exoledb.dll and Interop.Exevtsnk.dll).

6) Delete reference to System.Data and add references to:

- C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\System.Data.dll
- C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\mscorlib.dll

7) Build solution and get the event sink dll (.dll).

8) Register the sink in the same way you did on the 32 bit platform: regasm.exe .dll /codebase.

9) Create the COM+ in the same way you did on the 32 bit platform.

10) Register with regevent.vbs in the same way you did on the 32 bit platform: cscript regevent.vbs add "onsave" file://./backofficestorage/domain/MBX/mailbox/calendar/RegEvent.EML