Deployment of outlook plugin

Oct 2, 2014 at 11:07 PM
Hi,

im trying to deploy an outlook plugin without success so far.
if i run it from VS in debug mode it works, but if i try to create an installer (using ISS and also using a console app as an installer) it doesnt.

the installer registers the dll via regasm (and i sometime do it manually as well, via cmd), and also runs the following code as it was in the sample project:
RegistryKey key = Registry.ClassesRoot.CreateSubKey("CLSID\\{" + "85E0BBAF-11E7-4F70-957D-5682602A0933".ToUpper() + "}\\InprocServer32\\1.0.0.0");
                            key.SetValue("CodeBase", @"file:///" + @codeBase);// + "OutlookAddin.dll");
                            key.Close();

                            key = Registry.ClassesRoot.CreateSubKey("CLSID\\{" + "85E0BBAF-11E7-4F70-957D-5682602A0933".ToUpper() + "}\\InprocServer32");
                            key.SetValue("CodeBase", @"file:///" + @codeBase);// + "OutlookAddin.dll");
                            key.Close();

                            // add bypass key
                            // support.microsoft.com/kb/948461
                            key = Registry.ClassesRoot.CreateSubKey("Interface\\{000C0601-0000-0000-C000-000000000046}");
                            string defaultValue = key.GetValue("") as string;
                            if (null == defaultValue)
                                key.SetValue("", "Office .NET Framework Lockback Bypass Key");
                            key.Close();

                            // add outlook addin key

                            Registry.ClassesRoot.CreateSubKey(@"CLSID\{" + "85E0BBAF-11E7-4F70-957D-5682602A0933".ToUpper() + @"}\Programmable");
                            Registry.CurrentUser.CreateSubKey(_addinOfficeRegistryKey + _prodId);
                            RegistryKey rk = Registry.CurrentUser.OpenSubKey(_addinOfficeRegistryKey + _prodId, true);
                            rk.SetValue("LoadBehavior", Convert.ToInt32(3));
                            rk.SetValue("FriendlyName", _addinFriendlyName);
                            rk.SetValue("Description", _addinDescription);
                            rk.Close();
Is this piece of code needed or only the regasm?

also, at the top of the Addin class i added this code:
[COMAddin("OutlookAddin", "Outlook Addin", 3)]
    [GuidAttribute("85E0BBAF-11E7-4F70-957D-5682602A0933"), ProgId("OutlookAddin"), ComVisible(true)]
    [RegistryLocation(RegistrySaveLocation.LocalMachine)]
This is somewhat similar to the code for the office plugin.

I also have similar problem to one that was reported here before - if RegistrySaveLocation.CurrentUser or localMachine is chosen, the registry key will be created under currentUser anyhow and not LocalMachine.

So after all that, when i run the installer i can see the reg keys created but i get a loading error for the plugin and the LoadBehavior changes to 2 instead of 3. again, if i run it from debug mode in VS it runs ok, so the issue is not the code itself i suspect.

using net.office 1.6.0, winxp, outlook 2010, .net 4, vs 2010 express.

thanks.
Coordinator
Oct 4, 2014 at 4:58 AM
i wondering about NetOffice is used in space. But nice to hear because a german is currently on the ISS.

About CurrentUser/Local Machine. This is a known bug in NO 1.6 :( i'm sorry. As hotfix i suggest you to overwrite the registry methods and create the reg keys at hand.

Regasm register the COM component himself, this means the assembly is now just visible for the COM runtime system. (and Office is a COM application, fun fact: Visual Studio.NET is also a COM application) Its always your turn to create the office reg keys. (NetOffice try to do this a bit easier with some special annotations, btw. your addin inherites from Tools.COMAddin?)

The common exception is a security issue. you need admin privileges to register a COM component(and write access to local machine key). Moreover its cause issues to do this in a non desktop account(IIS network or system account) Its not clearly for me its a register or loading problem. Do you have any exception details so i can pin point the problem?

*Sebastian
Oct 4, 2014 at 1:19 PM
Edited Oct 4, 2014 at 2:35 PM
Hi,

so after some more experiment i found out that:
1/ the code i mentioned above is sufficient to deploy bot office and outlook addons.

2/ i found out that if i register the outlook addin, or build the code, it works. I can then unregister the addon and it is removed from outlook.

But then:
1/ if i try to register the same dll again, it doesnt work.
2/ if i try to build again, still doesnt work.
3/ only when i rebuild the project it then works again.

I'm trying to create a installer/uninstaller so i need this to work. Any ideas on why and how?

thanks again.





Hi Sebastian,

I'm sorry to disappoint you, but by ISS i meant Inno Setup - the software i create installer with.

But i just hosted 2 German couch surfers at my house for 2 days and enjoyed their stay very much. :-)

Anyhow, about the LocalMachine\CurrentUser - it's not a big deal - i saw i can change it on the ComRegisterFunctionAttribute and it changes to location of the reg keys for the outlook addon. For the office addon the reg keys are created at the localMachine level as needed.

I have two addins, one for Office and one for Outlook.
Now, you said that its always my turn to create the reg keys, but i found that the RegAsm does that for me. I think its because this code is present at the office addin:
[COMAddin("OfficeAddin", "Archive Addin", 3), CustomUI("OfficeAddin.RibbonUI.xml"),
    RegistryLocation(RegistrySaveLocation.LocalMachine),
    MultiRegister(RegisterIn.Excel, RegisterIn.Word, RegisterIn.PowerPoint)]
Is that correct?

Now, for the Outlook addin the reg keys are also created when using RegAsm.
i assume its done by the [ComRegisterFunctionAttribute] function? is that correct?
i also added this code, which im not sure is necessary. Is it?
 [COMAddin("OutlookAddin", "Outlook Addin", 3)]
    [GuidAttribute("85E0BBAF-11E7-4F70-957D-5682602A0933"), ProgId("OutlookAddin"), ComVisible(true)]
    [RegistryLocation(RegistrySaveLocation.LocalMachine)]
So, bottom line, if the keys are created by regAsm because of the presence of the codes mentioned, is that enough and should deploy the addin successfully? Because the office addin works for me but the outlook one doesnt. I get a message in outlook that sais the load failed and the addon load behavior is changes to 2 in the reg key.

thanks again.
Oct 4, 2014 at 2:41 PM
So, regarding this:
"I'm trying to create a installer/uninstaller so i need this to work. Any ideas on why and how?"

Maybe its a .NET issue, but when i unregister a dll and then reregister it, it doesnt work. What i finally setteled on is removing the addon from Outlook instead of unregistering the dll. that way the next time i register it it does show up on office.

So, seems like everything is working. Thanks for the help. I'm leaving the questions here for future reference.

Anyone who has issues with deployment are invited to contact me.



ehudklein wrote:
Hi,

so after some more experiment i found out that:
1/ the code i mentioned above is sufficient to deploy bot office and outlook addons.

2/ i found out that if i register the outlook addin, or build the code, it works. I can then unregister the addon and it is removed from outlook.

But then:
1/ if i try to register the same dll again, it doesnt work.
2/ if i try to build again, still doesnt work.
3/ only when i rebuild the project it then works again.

I'm trying to create a installer/uninstaller so i need this to work. Any ideas on why and how?

thanks again.





Hi Sebastian,

I'm sorry to disappoint you, but by ISS i meant Inno Setup - the software i create installer with.

But i just hosted 2 German couch surfers at my house for 2 days and enjoyed their stay very much. :-)

Anyhow, about the LocalMachine\CurrentUser - it's not a big deal - i saw i can change it on the ComRegisterFunctionAttribute and it changes to location of the reg keys for the outlook addon. For the office addon the reg keys are created at the localMachine level as needed.

I have two addins, one for Office and one for Outlook.
Now, you said that its always my turn to create the reg keys, but i found that the RegAsm does that for me. I think its because this code is present at the office addin:
[COMAddin("OfficeAddin", "Archive Addin", 3), CustomUI("OfficeAddin.RibbonUI.xml"),
    RegistryLocation(RegistrySaveLocation.LocalMachine),
    MultiRegister(RegisterIn.Excel, RegisterIn.Word, RegisterIn.PowerPoint)]
Is that correct?

Now, for the Outlook addin the reg keys are also created when using RegAsm.
i assume its done by the [ComRegisterFunctionAttribute] function? is that correct?
i also added this code, which im not sure is necessary. Is it?
 [COMAddin("OutlookAddin", "Outlook Addin", 3)]
    [GuidAttribute("85E0BBAF-11E7-4F70-957D-5682602A0933"), ProgId("OutlookAddin"), ComVisible(true)]
    [RegistryLocation(RegistrySaveLocation.LocalMachine)]
So, bottom line, if the keys are created by regAsm because of the presence of the codes mentioned, is that enough and should deploy the addin successfully? Because the office addin works for me but the outlook one doesnt. I get a message in outlook that sais the load failed and the addon load behavior is changes to 2 in the reg key.

thanks again.
Coordinator
Oct 10, 2014 at 6:24 PM
the annotations looks good so far...
if its possible, please send me a sample solution(incl. you current NO assemblies!!!) to public.sebastian[at]web.de
its the easiest/fastest way to pin point the problem. please remove any private code because no need for.

*Sebastian
Oct 16, 2014 at 5:33 PM
Hi,

I found what the problem was. For some reason, although the reg keys are created ok, and the codebase path is correct, when office starts it looks for the files under office's installation folder (in program files) instead of the path defined in the registry. I found that out using office addins debug loggin as explained here:

http://blogs.msdn.com/b/vsod/archive/2008/04/22/troubleshooting-com-add-in-load-failures.aspx

If i place the files under the office installation folder it works fine. The problem is that both the office and outlook addins should be deployed there, and office and outlook addon have different officeapi.dll files. I opened a new discussion on that subject.

thanks for all the help.