This project has moved. For the latest updates, please go here.

How do you get a com addin working?

Feb 10, 2015 at 2:16 AM
I have used VSTO for years but can't even get a HelloWorld working as a com addin in outlook. There does not seem to be any steps listed to manually setup one so it can be tested??

Is there a tutorial on how to actually get this done?

Thanks for your help.
Coordinator
Feb 10, 2015 at 4:52 PM
you find examples for each office product in the release folder.

Excel(.NET 40) in C# for example:

"Release\NET4.0\Examples\Excel\C#\NetOffice COMAddin Examples"

You have to make sure the addin is registered(during regasm.exe) on the dev and/or deploy system - thats all.

*Sebastian
Feb 12, 2015 at 12:07 AM
Thanks for your reply Sebatian there are good examples of code but not much on how to register the addin etc

OK got it working now with a bit of fiddling this is what I did in case anyone else doesn't know and or is as slow as me :) :

I did a simple example to show it was working just a helloworld in the Addin_OnStartupComplete frunction.

1) Built the project
2) used regasm
regasm.exe c:\[My Path]\HelloWorld.dll /codebase
That does some magic and places an empty registry entry under the office app you made the addin for

HKEY_CURRENT_USER\Software\Microsoft\Office\Outlook\Addins\HelloWorld.Addin

3) Fill in the empty registry entry with values I copied another addin that was working the important values seem to be
LoadBehavior Reg_DWord hex3 (3 = open at load)
Friendly Name REG_SZ ""
Description REG_SZ ""

Restart the app in my case outlook and it worked.
Coordinator
Feb 12, 2015 at 12:53 AM
you dont have to call regasm at hand on your dev system if the project option "Register For Com Interop" is enabled. (true in NO examples)
In this case Visual Studio calls regasm.exe for you after compile. make sure to start VS with admin privileges otherwise a permission exception ocurred.

An empty created reg key is an unexpected behavior so far. do you use the tools or normal IExtensibility2 sample?

In NO Tools:
the registry values(LoadBehavoir,...) want set while register(trough regsam) with the annotation informations from your addin class.
here you can see the annotations with loadbehavior=3
[COMAddin("Addin FriendlyName", "Addin Description", 3), RegistryLocation(RegistrySaveLocation.CurrentUser)]   
[Guid("B3F60319-1A11-4F3E-9C1B-3AE908D9CA86"), ProgId("SampleLib.Addin")]
public class Addin : COMAddin
{
}

*Sebastian
Mar 5, 2015 at 1:26 AM
Hi Sebastian,

I run "regasm <dll name> /codebase" under Office 2013 but I could not see the custom tab or buttons.
In the Word Options dialog, under the Add-ins, I did not see my add-in.
I did not have problem on Office 2010.

I've used the Developer Toolbox and verified that my dll supports 2013.

What did I miss out?

Thanks.
Mar 5, 2015 at 2:17 AM
long1000 wrote:
Hi Sebastian,

I run "regasm <dll name> /codebase" under Office 2013 but I could not see the custom tab or buttons.
In the Word Options dialog, under the Add-ins, I did not see my add-in.
I did not have problem on Office 2010.

I've used the Developer Toolbox and verified that my dll supports 2013.

What did I miss out?

Thanks.
Wait, I actually have the same problem on Office 2010 if I didn't run it from Visual Studio.
If I run Word from Program Files direct, I could not see the custom buttons.
If I run Word from Visual Studio, then I can see the buttons.

I tried on Office 2003 but cannot see any buttons as well.
Then, I compiled and regasm the sample NetOfficeTools.SimpleWordCS2.dll but still, I couldn't see any custom buttons.

Where did I do wrong?
Thanks.
Coordinator
Mar 5, 2015 at 11:56 PM
hey men,

for me, this sounds like a dependency(assembly) is missing because it works as well in visual studio.
do you use more than the well known .net references in your solution?

*Sebastian
Mar 6, 2015 at 12:42 AM
Edited Mar 6, 2015 at 1:49 AM
No, it wasn't dependency. Its a registration problem.
I got it working on Office 2007. Had to unregister and then, re-register it again.

However, I still have no luck with Office 2013.
After I register it, I couldn't see my addin in the Word Options dialog, under the Add-ins section.

I currently compile the addin with AnyCPU option.
Does it matter if I regasm it in 32 or 64 bit windows?

When I regasm the sample NetOfficeTools.SimpleWordCS2.dll and SuperAddinCS2.dll, they are placed under the "Inactive Application Add-ins" in the Word Options dialog, under the Add-ins section. Did I miss anything?

Thanks.