How to re-add a deleted VSTO Add-In

五迷三道 提交于 2019-12-10 14:53:15

问题


I've got a strange issue with a Word VSTO add-in on one machine where running the visual studio project opens word but does not attempt to start the add in as far as I can tell.

I got to this point because I accidentally clicked Remove for the Add-in on the Manage COM Add-ins page, instead of re-enabling it after a failure.

I want to know how to re-enable a deleted add-in - I'm thinking that perhaps there is a registry key somewhere I need to get rid of.

  • When I run the project from Visual Studio it does not attempt to start up at all, Word starts instantly with no "something-is-failing" type pause.
  • No breakpoints in ThisAddIn_Startup are hit.
  • In Word : File/Options/Add-ins - the add-in does not appear under Inactive or Disabled Addins
  • Word : Manage COM Add-ins Go... it does not appear.
  • Word : Manage Disabled Items Go... is empty.

I've tried installing and uninstalling the published version, to see if that wakes anything up, and I've tried changing the path of the VS project, just in case that makes a difference (and various restarts, cleans, rebuilds, locally deleting and re-cloning from git etc) but I can't find a way to get this to work again. On a different machine, cloning the add-in from Git and opening it in Visual Studio and its all fine.

I've tried re-adding via the select DLL (or select .) dialog on the COM Add-ins but nothing I select appears to be a valid add-in.

Any help to figure out how to get back to a working development environment would be appreciated.

EDIT There's a lot going on below - so I thought I'd clarify that the successful solution was the online-repair of Office


回答1:


What is the LoadBehaviour in the registry? It should be 3...

To find out, look in

  • 32bit Word => Root\Software\Microsoft\Office\Word\Addins\add-in ID
  • 64bit Word => Root\Software\Wow6432Node\Microsoft\Office\Word\Addins\add-in ID

where Root is HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE, depending on whether the addin is installed for current user or everyone.

If the value for LoadBehaviour is not 3, then change it to 3 and restart Word.

Here is the Microsoft docs about it: Registry entries for VSTO Add-ins

If it still does not work, try to re-enable as it might be hard disabled:

  • In the Manage box, change COM Add-ins to Disabled Add-ins, and click Go.
  • Select the add-in and click Enable. Click Close. Now the add-in can be loaded again...
  • Back in the Manage box, change Disabled Add-ins to COM Add-ins, and then click Go.
  • Check the checkbox next to the disabled add-in. Click OK.

Here is the Microsoft docs about it: How to: Re-enable a VSTO Add-in that has been disabled

Also, if you haven't done this already, it is worth setting VSTO_SUPPRESSDISPLAYALERTS to 0 as described on this page: How do I enable VSTO error / display alerts?

If none of the above helps, then it is worth doing a Online repair of Office from Add or Remove Programs.




回答2:


I believe that you need to change the version of the VSTO add-in in order to be able to update it or re-install it. Once an add-in version has been disabled, this is permanent.

See Uninstall MS Word Add-in for details. Let me know if that worked.




回答3:


The most extreme steps I've had to take when things aren't working as expected are to clear out the VSTA cache, either in the registry or the filesystem. Note that I work with template-based customizations that are attached to documents, not add-ins that are always present, so this may not apply to you. Or maybe it does, I don't know.

Registry

Look for an entry for your add-in under HKCU:\Software\Microsoft\VSTA\Solutions. I use PowerShell for this, and an example command chain would be something like this:

gci "HKCU:\Software\Microsoft\VSTA\Solutions"


    Hive: HKEY_CURRENT_USER\Software\Microsoft\VSTA\Solutions


Name                           Property                                                                                                                                                                                     
----                           --------                                                                                                                                                                                     
1234abcd-1234-abcd-1234-abcd12 Url                 : file:///Z:/path/to/your/addin.vsto                                                              
34abcd                         SubscriptionID      : addin.vsto, Culture=neutral, PublicKeyToken=<removed>, processorArchitecture=msil                                                                        
                               ApplicationID       : file:///Z:/path/to/your/addin.vsto#addin.vsto, Version=<removed>, Culture=neutral, 
                                                     PublicKeyToken=<removed>, processorArchitecture=msil/addin.dll, Version=<removed>, Culture=neutral, PublicKeyToken=<removed>,                     
                               processorArchitecture=msil, type=win32                                                                                                                                                       
                               ProductName         : addin                                                                                                                                                           
                               LastCheckedTime     : {4, 201, 185, 1...}                                                                                                                                                    
                               UpdateEnabled       : 1                                                                                                                                                                      
                               UpdateInterval      : 1                                                                                                                                                                      
                               UpdateIntervalUnits : days            

remove-item "HKCU:\Software\Microsoft\VSTA\Solutions\1234abcd-1234-abcd-1234-abcd1234abcd"

Filesystem

My customizations (see note at the start) are installed at %localappdata%\Apps\2.0 and on rare occasions I need to delete them manually. Clearing this one out is less straightforward, but usually there's a single anonymized folder like ABCDEFG0.QWE. I just delete that, and along with the other half of this, I've never run into a problem I couldn't solve. FYI if you have multiple deployments this might uninstall all of them. I don't do it very often so I'm not 100% familiar with how this area works, but I've never made anything worse by doing this.

I don't know how this differs, if at all, for application-level add-ins, that can be installed to Program Files.

Edit: adding some relevant links.

How do I completely uninstall a ClickOnce application from my computer?

Clear the .NET-downloaded application cache without Mage?



来源:https://stackoverflow.com/questions/56224143/how-to-re-add-a-deleted-vsto-add-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!