![]() |
Languages »
C# »
General
Intermediate
License: The Code Project Open License (CPOL)
Outlook Plug-in using COM Shim (C#)By GigyOutlook Plug-in using COM Shim wizard |
C#1.0, Windows, .NET1.1VS.NET2003, Dev
|
||||||||
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||

This is a plug-in created for Outlook 2003 using C# and COM Shim wizard . This COM Shim wizard will come only when you install COMShimWizardSetup.msi, which can be downloaded from the Microsoft site. After installation you will get this wizard under Visual C++ Projects. This wizard is used to create a pure COM DLL. This is initiated by some similar project from code project. But I don't have that link at this moment to add the reference.
I started creating the Outlook plug-in VC++ using the Shared - Addin wizard in VS 2003. The plug-in was working quite fine in all machines without much extra effort. Since the plug-in DLL created in VC++ was just a COM DLL and will get integrated with the Outlook application very easliy (I just closed my eyes for the programming effort ;) ). Once I started migrating the code from VC++ to C# for enhancing the plug-in issues arose.
Almost all the code will be added by the wizards except your customization code. There are detailed explanation in Microsoft site about how to use Shared Add in and the Shim Wizard . The picture given below is taken from Microsoft site which tells about the use of Shim dll

The plug-in created using C# is called managed dll or rather managed assembly. When this has to load with some application, the CLR ( mscoree.dll) will do the proper conversion of this MSIL code to machine code . This works quite fine if all the security policies has followed as per Dot Net convention .
Deploying and installing a managed COM add-in securely in Microsoft� Office XP currently requires the assembly be hosted in an unmanaged COM add-in proxy component called a shim.
The shim is a Visual C++ Active Template Library (ATL) COM DLL. It exposes a COM-creatable class that acts as a proxy to the real managed extension class. The COM Shim Wizard registers the CLSID and ProgId for this class in the registry. In the case of COM add-ins and smart tags, the wizard also registers this class against all the target Office applications you choose. When the host Office application starts, it checks the registry to see which add-ins and smart tags to load, and then uses standard COM object creation to instantiate the registered proxy class. This action loads the COM shim DLL that is registered to proxy one of the add-ins or smart tags.
I moved the created snk file to the project parent folder and modified the AssemblyInfo.cs in the following manner:
[assembly: AssemblyKeyFile("..\\..\\CodeProjectTest.snk")]
Only thing need to be take care is, we use the proper References. Here we need to use the interop assemblies. Component Object Model (COM) interop assemblies allow unmanaged (COM) code to be called from managed (.NET) code by using the Microsoft .NET Framework and the common language runtime. COM interop assemblies allow managed applications to bind to unmanaged types at compile time and provide information to the common language runtime about how the unmanaged types should be marshaled at run time.
It is important for security reasons to never fail to include the public key token in the ShimConfig.cpp file. This will get added by default through Shim wizard, if you have followes the proper steps
First Draft: 27 December 2006
| You must Sign In to use this message board. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads.
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 27 Dec 2006 Editor: |
Copyright 2006 by Gigy Everything else Copyright © CodeProject, 1999-2010 Web09 | Advertise on the Code Project |