views:

672

answers:

2

Hi all,

I've had someone else's pile of stuff handed to me. Among these items is a Word 2003 add-in (VSTO 2005 SE, .NET 2.0) that reportedly had been working fine in 2007, but our deployment environment calls for 2003. It installs apparently fine for Office 2003 -- no errors, shows up in add/remove -- but the toolbar is unavailable within Word itself.

Supposedly this works fine in someone's test environment, but I've never seen it working in our common dev environment. We have a setup/deploy project with both a MSI and setup.exe. (I tried packing stuff in CABs just in case, I've tried it with prereqs indepdently installed, no apparent difference.)

The MSI, the setup.exe, right-click installing the setup/deploy project in Visual Studio, none of these methods report an error -- but none of these methods succeed in showing the toolbar in Word 2003 on Server 2003 either. However, if I point Visual Studio at winword.exe for debugging and start the project, the add-in button shows up. It continues showing up on later, independent client startups. It remains available as a toolbar until I explicitly remove it via add/remove or right-click uninstall or running the MSI and removing.

So now I'm at a loss -- what is happening by running in debug that isn't happening during a typical setup/deploy installation?

EDIT: ok, updates. Created a clean VSTO 2005 add-in for Word 2003, new add-in name, clean slate. The same behavior is experienced with a naked project, virgin registry, on both Server 2003 and XP Pro. I'm a local admin on XP, I'm a domain admin on the 2003 box.

+1  A: 

Here are some questions for troubleshooting:

  • What kind of add-in are you developing? A Shared Add-in or a VSTO? If VSTO which version?
  • What OS are you using? Vista can be tricky...
  • Check the LoadBehavior of your add-in in the Registry. You find the value either in

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\Word\Addins\<add-in class name>\
    

    or

    HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\Word\Addins\<add-in classname>\
    

If the value of LoadBehavior is 2 your add-in has been disabled during startup. This happens when Word cannot instantiate the add-in, typically because the add-in throws an unhandled exception, or - much more often - because the add-in is not correctly registered.

Have you checked that the VSTO runtime is correctly installed on the target system?

However, even if you use VSTO, for Word the add-in still looks like a classic COM add-in which is extending the classic IDTExtensibility2 interface. Such add-ins must be registered the following way:

  • One of the two registry keys above to tell Word the class name of the add-in plus additional information such as the load behavior and a description
  • The class name of the add-in must be registered under

    HKEY_CLASSES_ROOT\<add-in classname>\CSLID
    
  • The correct version of the COM component must be registered under (where {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} is the guid of the component as specified under HKEY_CLASSES_ROOT\\CSLID):

    HKEY_CLASSES_ROOT\CLSID\{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
    

The following two links might also help you further narrowing down your problem:

HOWTO: Troubleshooting Visual Studio and Office add-ins

Troubleshooting Outlook COM Addins – Using ProcMon

0xA3
As noted, VSTO (I think -- for some reason the guy also had a prereq for the shared add-in KB hotfix) and Server 2003. Unfortunately LoadBehavior isn't any different between when it works, and when it does not work. (Thanks for pointing out local user though, I was wondering why !in local machine.)
andrewbadera
Sorry, actually load behavior might vary between 2 and 3, but either value results in no difference.
andrewbadera
OK, so it starts out as 3, then after Word starts sans add-in, the value becomes 2. Is there a log somewhere I can investigate?
andrewbadera
Thanks for all the great info, still digging ... VSTO runtime seems fine, reinstalling just in case. What I just don't get is why it runs fine in Visual Studio debug, and after being debugged, it runs fine standalone, but won't run standalone after initial install.
andrewbadera
Have you tried deleting (renaming) all relevant registry keys for the add-in installation and then re-installing the add-in? It might be that your the debugger added another version under the CLSID key which is confusing Word.
0xA3
Could you put the dump of the relevant registry keys here?
0xA3
Just got into the office this morning, I'll try cleaning it out. Thing is, the reason this was dumped on me was because someone else also had issues in their own dev/test environment, and couldn't resolve them, so it was passed on to me.
andrewbadera
They report they got it working on a barebones Server 2003 setup, unfortunately, that's not a luxury I can afford. I'll get a dump of the stuff after a cleanup and reinstall, thanks again.
andrewbadera
But either way, these issues were experienced in another environment, with no Visual Studio debugger attachment.
andrewbadera
Thanks for the top on ProcMon -- GREAT utility. Unfortunately, it's not revealing anything but successful operations. It DOES show me where LoadBehavior gets set to 2, but there's no indication why. Haven't done a line-by-line comparison yet; right now trying a VPC that's outside this environment.
andrewbadera
+1  A: 

EDIT: Full Trust for the add-in assembly ended up being the fix. Doesn't seem to run at anything less than Full Trust.

//

Ended up opening a ticket with Microsoft, and they've educated me about VSTO_SUPPRESSDISPLAYALERTS:

http://msdn.microsoft.com/en-us/library/ms269003(VS.80).aspx

This value defaults to 1; setting it to 0 provides a popup dialog with the exception otherwise being buried.

Still working out the details, and I'll continue to update this thread, but now we finally have a basis on which to move forward:

Could not load file or assembly 'PrintTest2007, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Failed to grant permission to execute. (Exception from HRESULT: 0x80131418)


************** Exception Text **************
System.IO.FileLoadException: Could not load file or assembly 'PrintTest2007, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Failed to grant permission to execute. (Exception from HRESULT: 0x80131418)
File name: 'PrintTest2007, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' ---> System.Security.Policy.PolicyException: Execution permission cannot be acquired.
   at System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Boolean checkExecutionPermission)
   at System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Int32& securitySpecialFlags, Boolean checkExecutionPermission)
   at Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.HandleOnlineOffline(Exception e, String basePath, String filePath)
   at Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.LoadStartupAssembly(EntryPoint entryPoint, Dependency dependency, Dictionary`2 assembliesHash)
   at Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.ConfigureAppDomain()
   at Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.LoadAssembliesAndConfigureAppDomain(IHostServiceProvider serviceProvider)
   at Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.LoadEntryPointsHelper(IHostServiceProvider serviceProvider)
andrewbadera