Monday, December 14, 2015

Fixing Deployment.AddInAlreadyInstalledException.



If you are building any VSTO for any of the office applications, then its quite common to run into this issue.


The error message would say that

"The customization cannot be installed because another version is currently installed and cannot be upgraded from this location. To install this version of the customization, first use Add or Remove Programs to uninstall this program: TestUpdatedVersion. Then install the new customization from the following location: file:///D:/Samples/TestUpdatedVersion/bin/Debug/TestUpdatedVersion.vsto ********** Exception Text ********** Microsoft.VisualStudio.Tools.Applications.Deployment.AddInAlreadyInstalledException: The customization cannot be installed because another version is currently installed and cannot be upgraded from this location. To install this version of the customization, first use Add or Remove Programs to uninstall this program: TestUpdatedVersion. Then install the new customization from the following location: file:///D:/Samples/TestUpdatedVersion/bin/Debug/TestUpdatedVersion.vsto at Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInDeploymentManager.VerifySolutionCodebaseIsUnchanged(Uri uri, String subscriptionId, Boolean previouslyInstalled) at Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInDeploymentManager.InstallAddIn()"


So let me explain a fool proof way to troubleshoot this. Would be quite useful for Support Engineers.


  1. Go to Control Panel and search for this application plugin. If its listed then try to uninstall this and then re run the set-up. If its not listed or re-running the setup.exe fails then continue with step 2.
  2. Try cleaning up registry and installed file list by using a "Fix it" package from Microsoft, available here https://support.microsoft.com/en-us/mats/program_install_and_uninstall
  3. Now most probably the application is uninstalled but it has left behind some registry. So let clear them. 
  4. Press Start+R. In run command prompt type regedit and press enter.
  5. Clear any application related keys from 
  6. In registry editor go HKEY_CURRENT_USER\Software\Microsoft\Office\/Addins/
  7. to HKEY_CURRENT_USER\Software\Microsoft\VSTO\SolutionMetadata\{GUID} and clean up the entry for the VSTO. Check on the right side of the screen to figure out the right registry entry.
  8. Then check if there is an entry for HKEY_CURRENT_USER\Software\Microsoft\VSTA\Solutions\{GUID}. If there exists an entry then clear this up too. 
  9. Now First you would have to install Visual Studio 2013 Community edition from here https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx,
  10. This should result in download of mage.exe with its dependencies. https://msdn.microsoft.com/en-us/library/acz3y3te(v=vs.110).aspx Then going to C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin you should see mage.exe there.
  11. Then cd into the location for mage.exe in commandprompt.
  12. Run the following command there: mage.exe -cc. It should produce an output "Application Cache Cleared"
  13. Now reinstall the VSTO by running the setup.exe. This time it should go through for sure. If it does not then please do leave a comment.