Shimming: A Solution to the Problems with mscoree.dll





Shimming: A Solution to the Problems with mscoree.dll

Despite the gloomy picture painted for COM add-ins being loaded by mscoree.dll, a solution resolves these three problems. The solution involves writing a custom CLR host DLL called a shim DLL (written in C++) to be the loader for the CLR and the COM add-in instead of relying on mscoree.dll. A new shim DLL must be created for each COM add-in you are going to deploy. Using a shim DLL leads to a number of advantages:

  • Integration with the Office security system Now the shim DLL will be the InProcServer32 for the COM add-in, allowing you to sign the shim and trust it on the users' machines, which will guarantee that your COM add-in can load irrespective of whether Trust All Installed AddIns and Templates is checked. The COM add-in is guaranteed to load only if the user has trusted the certificate used to sign the custom shim DLL, of course.

  • Reliability Because the shim DLL is now the InProcServer32 for the COM add-in, if something should go wrong with that COM add-in, the Office application will block only the shim DLL corresponding to that COM add-in, leaving other managed COM add-ins unblocked.

  • Isolation The shim DLL can create an AppDomain into which the COM add-in will be loaded instead of loading the COM add-in into the default AppDomain.

If you are building a managed COM add-in for Outlook 2003, consider using the new VSTO Outlook Addin project. Building an add-in in this way resolves the problems with mscoree.dll, as well as some other Outlookspecific issues with add-ins described in Chapter 24, "Creating Outlook AddIns with VSTO."

Microsoft has provided a Visual Studio COM add-in shim wizard project that works with Visual Studio 2003. It is available at http://msdn.microsoft.com/office/default.aspx?pull=/library/enus/dno2k3ta/html/ODC_Office_COM_Shim_Wizards.asp. At the time this book was written, no wizards were available for Visual Studio 2005. You can use the C++ COM shim project generated by this wizard in Visual Studio 2003, however, and import it into Visual Studio 2005.



 Python   SQL   Java   php   Perl 
 game development   web development   internet   *nix   graphics   hardware 
 telecommunications   C++ 
 Flash   Active Directory   Windows