COM shim wizard for Visual Studio 2005
Finally! It took an eternity to get this thing published, but now you can go to MSDN and download COM shim wizard that work with Visual Studio 2005. Original COM shim wizard only worked with Visual Studio 2003 and so many people have requested an upgrade.
For those unfamiliar with the shims here is a short summary: if you are a C# or VB.NET developer writing a COM AddIn for Word, Excel, PowerPoint you want to isolate your AddIn from other managed components that are executing in the process. Here are some of the reasons for doing that. In other words you want to have your AddIn to run in the comfort of its own AppDomain. In the absence of proper VSTO support in this area, you would need to write your own unmanaged loader - yes, this is C++! The wizard can help you out here. After download and installing the COM shim wizard you will be able to create your own native loader in under 2 minutes. The best part - knowledge of C++ is optional.
Go to the background article or skip directly to the download.
Update Dec. 07 2007 : The very last and the best version of the com shim wizard is published here . It has a very nice advantage over previous versions because it uses COM aggregation technique (as opposed to COM containment) to execute the calls. This makes it completely unnecessary to duplicate interfaces on the native proxy class when you add those to the managed class. It also solves the ribbon callbacks issue (see Dmitrii's comments to the post).
Comments
Anonymous
October 22, 2006
The comment has been removedAnonymous
October 23, 2006
Interesting ... I have never tried this on Access, so this will need some more investigation (which I can not do right now :() I would assume that something else calls CorBindToRuntimeEx but does not start the CLR.Anonymous
October 23, 2006
Hi Misha, I am writing an Excel COM add-in in Visual Studio 2005 targeting Office 2002 and Office 2003. The download page gives the impression it will only work for Office 2007. Would it be possible to confirm if this COM Shim will work when building COM add-ins for earlier versions of Office. many thanks RussellAnonymous
October 24, 2006
The shim itself does not rely on any particular version of Office be installed. So, yes, it should work with previous versions as well.Anonymous
October 31, 2006
Hi Misha, I have downloaded the COM shim for Visual Studio 2005 but there are no instructions telling me what to do next. Would it be possible to point me in the right direction. many thanks RussellAnonymous
November 01, 2006
Looks like the link to the article (which contains all the instructions) did get broken. So this was the opportunity to fix it! And here is the link in the cleart text: http://msdn.microsoft.com/library/?url=/library/en-us/odc_vsto2005_ta/html/Office2003ShimWizard2.aspAnonymous
November 01, 2006
Thank you for the link. I am using Visual Studio Tools for Office 2005 and there is no C++ Projects in this version. Does this COM Shim work with this version ? many thanksAnonymous
November 02, 2006
Sorry, COM shim is a native C++ project. The wizard just helps creating it for you, but you need the corresponding part of VS to be installed in order to compile it.Anonymous
November 02, 2006
Thanks, Is there a way to create a COM Shim for an add-in written using Visual Studio Tools for Office 2005.Anonymous
November 02, 2006
Shims are for shared add-ins only and you do not need to create a shim for VSTO addins. VSTO runtime does take care of the appdomain isolation for you when it is loading the add-in.Anonymous
November 02, 2006
If I create a Shared Add-in (using the IDExtensibility3 interface) that can be used with Office XP and Office 2003 using Visual Studio Tools for Office 2005 do I need to Shim it ? Sorry for the confusionAnonymous
November 28, 2006
Does Microsoft Plan to create VSTO addins for other Office Applications such as InfoPath, Project, or Visio? I am currently using the managed COM addin in VS 2005 approach to developing a MS Project addin. I think it would be nice to have this technology (VSTO) for all applications no just a few.Anonymous
November 28, 2006
VSTO2005SE supports add-ins for 6 Office apps - Excel, Word, Outlook, PPT, InfoPath and Visio. Unfortunately MS Project is not supported by available versions of VSTO. We are hoping we will be able to support MS Project as well but I can not commit to this. But as Eric Lippert has mentioned (http://blogs.msdn.com/ericlippert/archive/2003/10/28/53298.aspx) it takes a lot of Microsoft employees to change a bulb. Meanwhile you can just use the COM shim wizards to generate the shim for your project.Anonymous
December 05, 2006
How do we create a installation/Setup for the newly created Shim with our project? I'm not sure how to deploy it.Anonymous
December 10, 2006
So how do I use the COM shim wizard for an Office 2007 add-in? The shim doesn't implement IRibbonExtensibility and an Office 2007 add-in that wants to customize the Ribbon, needs to implement that interface. The result of using the current wizard is that my add-in crashes at runtime (I wonder why...maybe because my add-in implements IRibbonExtensibility but the shim doesn't?) When will the wizard be updated? Or should I just forget about COM shims for Office 2007 add-ins? Thanks, Patrick SchmidAnonymous
December 21, 2006
Hi Misha, Your blog has some very good details, and I would like to view the material referenced in the background article. Unfortunately, it is broken. Can you suggest an alternative location? DLAnonymous
February 19, 2007
Hi Misha, Thanks for the updated COM addin shim wizard -- we've been working around this for some time, and we're very glad to have the new version! We've been experimenting with loading our own .config files into the AppDomain that the shim creates for our solution, so that we can take advantage of the ability to define app-level properties. We've done this by modifying the C++ code that the wizard generates, in order to set the ConfigurationFile property on the DomainSetup object. This is tedious for each project, and we would prefer to have this extra code defined in the template that the wizard uses to create the project. I modified the source in the VCWizardsCOMShimsAddinShimTemplates1033 folder, but the wizard seems to be drawing from a different location. Can you fill me in? Or better yet, is this a change you folks can make and support in the released version of the wizard? We've been setting .ConfigurationFile to the name of the managed assembly filename, plus the .config extension -- that way the VS.NET project can manage that file natively. Thanks much...SteveAnonymous
February 19, 2007
Hi Steve I talked with Misha about the issue of editing the template files. One thing to check is whether or not you're editing the correct copy. When you install the COM Shim Wizards, the installer lays the template files down in a known location, typically %programfiles%MicrosoftCOM Shim Wizards 2.0.0.0. This is because at this time, the installer doesn't know where VS is installed. After laying down the files, a custom action runs, and this custom action figures out where VS is installed and then copies the templates to the expected location under %programfiles%Microsoft Visual Studio. VS finds these templates in this location - it never uses the "temporary" copies that were first installed. On another note, we're finishing off a new version of the shim wizards - the main difference is that the new version supports the new extensibility interfaces. I'll be posting details on my blog very soon. http://blogs.msdn.com/andreww/default.aspx AndrewAnonymous
February 19, 2007
Thanks Andrew (and Misha) -- I located the files in the "correct" location, and once I added my customized code to that location then my new projects contain the modified code as expected. I'd still like to hear comments about the use of .config files with assemblies loaded by the addin shim, and whether this could be added to the upcoming release (or future releases). VSTO projects support this capability, however we're not moving to VSTO at this time for other technical reasons. Configuration files in .NET afford many great capabilities for debugging and runtime application configuration, and I'd much rather see a supported method rather than the workarounds we're currently using. Thanks much -- SteveAnonymous
February 22, 2007
Sure, Andrew has added the .config support. The appdomain will load the config file from <shimdirectory><assemblyname>.dll.configAnonymous
March 03, 2007
We have a lot of the older CAPI .wll code for WORD2002. We see WORD2007 mentions a .wll add-in. Is the CAPI lib approach obsolete, or is VSTO the new way? We are C/C++ coders. Any advice on direction and tools welcomed.Anonymous
March 03, 2007
John, I am not familiar with WLLs so I can not really comment on the "obsoleteness" aspect of it. VSTO tools though are primarily for developing add-ins (which are a lot like COM add-ins) using managed code (C#/VB.NET). We (VSTO team) believe that it is the better way to go because you can take advantage of the rich functionality which is available as part of .NET Framework. So, I think, going forward the majority of investments are Office development would be around managed code, so you might want to start looking in this direction. Having C++ skills is always a plus though and can always come handy especially when you are developing hybrid solutions where managed code interoperates with native.Anonymous
March 18, 2007
The comment has been removedAnonymous
June 27, 2007
I just downloaded and installed version 2 of the COM Shim Wizard, and when I attempt to create a new Addin Shim project, I receive "Automation server can't create object" error dialog and the project is never created. I am running VS 2005 SP1 on Vista Business. Any clues?Anonymous
June 27, 2007
I believe I know what might be going on. When installing the COM shim wizard you are asked whether to install for "Just me" or "Everyone". The default is "Just me". This default would work for all OSs including Vista unless you do run VS 2005 in elevated mode (which I assume you do since this is how VS 2005 is recommended to be used on Vista). The workaround is to ininstall the COM shim wizard and then install it for "Everyone".Anonymous
June 28, 2007
That did the trick! Thanks for your reply.Anonymous
July 02, 2007
Hi Misha, After installing the shim, I am gettin this error "Not loaded. A runtime error occurred during the loading of the COM Add-in". The same installer works on couple of other machines (standard build w/o admin access). What could be reason for the failure of COM shim to load? Is there a way I can debug the add-in and figure out the error? Appreciate your response. Thanks, SingapuraAnonymous
July 02, 2007
Singapura, This might have either because your COM add-in is not registered correctly - in which case the shim will not be even loaded into the process, or, alternatively, if shim's OnConnection method fails. Also, if you are running on Vista and the shim is installed the COM discover might fail if:
- The shim was installed as "Just me"
- The host process is running elevated OR UAC is turned off on the machine Yes, debugging is possible. You will need to start host application under native debugger and put a breakpointer in the shim's code.
Anonymous
July 09, 2007
The comment has been removedAnonymous
July 09, 2007
Adam, I can take a quick look at your MSI file and see if I can figure it out. Please use Email link at the right top corner of this page to contact me.Anonymous
July 12, 2007
Ok, so i finally made some ground on whats going on, i made a basic addin and set it to be available for Word, Excel and Project. Then i compiled, tested, works. Now i followed the docs on making a shim with the wizard to a t, made it available for word, excel and project. Neither the add-in or the shim are signed just to get it working. Created the installer and installed, the AddIn works for word and excel but when it fires up in Project, nothing happens, and the LoadBehavior in the registry is set from 3 to 2. I know its not the AddIn code, is this a bug anyone else has run into? My addin is only for Project and i would love to get it running but im getting no where.Anonymous
August 14, 2007
The comment has been removedAnonymous
September 02, 2007
Hi Misha I 'm little confused about my Word 2003 Add-In deployment.
- I Have created the Word 2003 Shared Add-in with a strong key and build it using C#.
- Run the COM Shim wizard 2.0 and selected Word only
- Finished the Shim Wizard and build the C++ Project. I got "AddinShim1.dll" and "AddinShim1.tlb" in the Debug directory.
- On the default setup project that added with the Shared Add-in, I have added the "AddinShim1.dll" to "File System" and run 'Rebuild'. After deploying to another Win XP machine, the Add-in is loading with Word. Could you help me?
Anonymous
November 25, 2007
The latest version of the COM shim wizards was released back in the summer, here . With the help of AdamAnonymous
November 25, 2007
The latest version of the COM shim wizards was released back in the summer, here . With the help of AdamAnonymous
December 06, 2007
Hi Misha My Excel COMAddIn has ribbon and creates custom task panels. I can add IRibbonExtensibility and ICustomTaskPaneConsumer to Connection Proxy object but ribbon callbacks is a real problem. COM Shim has to be updated with every new method added to COM AddIn. I have created simple DLL project that loads mscoree.dll in DllMain and passes all calls to DllCanUnloadNow and DllGetClassObject to mscoree.dll. It seems to do the trick. All I do is sign my dll and replace mscoree.dll in InprocServer32 with full path to my dll. Do you know if this way can cause any problems? Thanks, Dmitri ZouchinskiAnonymous
December 07, 2007
Hello Dmitri, I would not recommend doing this trick mainly because your add-in is loaded into default AppDomain and if more than one add-in is loaded there - they might start stepping on each other's toes. The latest version of ShimWizard (http://msdn2.microsoft.com/en-us/library/bb508939.aspx) uses a little bit different technology for proxying - it is not even direct proxying but aggregation of interfaces exposed by the managed object. This makes the need to duplicate callbacks unnecessary. So, I suggest you to use this approach instead.Anonymous
December 07, 2007
Hi Misha, This is a great tool for isolation. i am working on an add-in for outlook 2003 and 2007 with c# (not VSTO), can i use this approach to add com shim project to my solution and release the project to production environment after testing cycle? thanks kishAnonymous
December 08, 2007
Hi Kish, The article is out there so that other people could use it. So, the answer is yes, of course!Anonymous
December 08, 2007
Hi Misha, I just came across your blog while searching on COM-SHIM :), its very informative!! We have used COM-SHIM version 2.3 in our Outlook Add-in which has been developed by using IDTExtensibility2. We are facing issues related to the after integration with the COM-SHIM project. Code Snippet: Outlook.ApplicationClass _app = new Outlook.ApplicationClass(); Outlook.Application olApp = (Outlook.Application)_app; Outlook.MAPIFolder root = Folder.GetRootFolder(olApp.Session); string folderName = FedExFolderManager.FedExFolderName; foreach (Outlook.MAPIFolder f in root.Folders) { if (f.Name == folderName) { f.Delete(); break; } } olApp = null; root = null;
//For example, this code was running fine before integration, but now it gives a null exception at (Outlook.MAPIFolder f in root.Folders) We are trying to meet deadline on fixing this issue here, any help on this COM-SHIM integration will be highly appreciated. Have a great day :) -Prasanjit
Anonymous
December 13, 2007
Misha Thank you for the advice. I have tried latest COM Shim Wizard and it works. Ribbon callbacks are now functional. I know I am whingeing but as I use Custom Task Pane I need .Net controls to be created from ProgId. Wizard only create proxy for COM AddIn. What are the consequences of leaving other controls from the same assembly in hands of mscoree.dll? Dmitri ZouchinskiAnonymous
December 13, 2007
Hello Dmitri, You will need to regasm your UserControl that will go into the Custom Task Pane. If you are OK with the registry impact of regasming - then it is fine - the control will be instantiated in the calling AppDomain. Alternatively you can use VSTO add-ins support which provides a registry-free way of instantiating controls for the Custom Task Pane.Anonymous
December 20, 2007
I love the 2.3 COM Shim wizard and have used in successfully in an Access 2007 application. I am having trouble installing the wizard in the Visual Studio 2008 environment. Is it compatible with VS 2008? Thanks! JayAnonymous
April 03, 2008
Jay, I did quick tests on VS 2008 and they do seem to work. However, our setup would not automatically install classes for VS 2008. Below are some manual steps you can do to set up wizards for VS 2008 On a machine with Visual Studio 2008 (notice that if you are working on Vista - the setup might fail. If this is happening - please let me know and I can provide working setup)
- Install Com Shim wizards
- Open explorer and navigate to %programfiles%MicrosoftCOM Shim Wizards v2.3.0.0
- From VCWizards directory: copy ComShims folder into %programfiles%Microsoft Visual Studio 9.0VCVCWizards folder
- Go back to %programfiles%MicrosoftCOM Shim Wizards v2.3.0.0
- From vcvcprojects: copy ComShims into %ProgramFiles%Microsoft Visual Studio 9.0VCvcprojects
- Now, go into %ProgramFiles%Microsoft Visual Studio 9.0VCvcprojectsComShims folder - you will see a bunch of vsz files. Open each and everyone of those files in an editor and replace: Wizard=VsWizard.VsWizardEngine.8.0 ----> Wizard=VsWizard.VsWizardEngine.9.0
- Start VS 2008 and you should be able to see and use the wizards now.
Anonymous
April 07, 2008
I have created an Addin for Outlook2007 that adds a button to the ribbon for a mail message that is being read. This worked fine but after creating the shim with v2.3 of the wizard Outlook crashes. Outlook starts OK but it is when I click on a message to read that it then crashes. I have tried to attach the debugger but I can't get that to work so it is hard to know how to track down the problem. Any ideas what is going wrong or how to debug it? AlistairAnonymous
April 07, 2008
Alistair, Did you try attaching native debugger to see what the problem is? let's take it offline - please use the email link to contact me directly.Anonymous
June 05, 2008
Hi Misha Very interesting article. It should solved my problem of conflict between my addin for outlook and mscrm outlook addin. I work on vista and Visual Studio 2008, but the com shim wizard failed to install. Can you provide me working setup? ThanksAnonymous
June 05, 2008
Ok, it works Misha! I have follow this : To install the COM Shim Wizard on Windows Vista To run the entire install process as elevated, click Start, right-click the Command Prompt, and then select Run as administrator. Run the COMShimWizardSetup.msi from the elevated command prompt. Select the Install for all users option, which registers the wizards to the HKLM subkey, where Vista can find the entries.Anonymous
May 06, 2009
Hi, I have written a C# COM add-in Using VS 2008 .I have deployed it in XP with Outlook 2007. I have used COM SHIM . My question is , will it work on Windows Vista with Outlook 2007 and 2003?