locked
The Add-in '<Add-in name>' failed to load or caused an exception. RRS feed

  • Question

  • The Add-in '<Add-in name>' failed to load or caused an exception.
    Would you like to remove this Add-in?
    If you choose 'yes', ...
    Error message: Unspecified error
    Error number: 80004005

    I have been experiencing this problem quite a few times when I moved my add-in project to some other folder, and open it after some time (I have forgot how I moved). I solved by creating a new project and copying the codes in. Recently I wanted to review and update an add-in project I did some time ago and that was how I solved the problem.

    I know copying all the codes to a new project is definitely not a wise way to solve this problem, esp for big projects or add-in that have to be distributed to others. Currently what I have is a very small project.

    Now I am learning about to extend my small add-in project bigger and I came across this video:
    How Do I: Add a Right-Click Menu Item in Visual Studio?
    http://msdn.microsoft.com/en-us/vstudio/bb614548.aspx

    I downloaded the source code, but I can't load the add-in. Very similar to the problem that had been troubling me all along.

    The readme file says:
    "To get the add-in to work when you run the code, copy the "RightClickOptions.AddIn" file into the Visual Studio Add-Ins folder, usually [my documents]\Visual Studio 2005\Addins. Also make sure to set the path within this file correctly, being the <Assembly> tag in the .AddIn xml file."

    I have changed the path to the path that had the RightClickOptions.dll, but it still doesn't work.
    But it doesn't not state what I should change the file name to. I tried to search online regarding similar issue but they were not helpful to me.

    How do I solve this problem?
    What if I just want to distribute an add-in, how do I get others to install the add-in conveniently, w/o hvg to change the path?

     

    Thursday, October 22, 2009 12:46 PM

Answers

  • I have reproduced (and solved) your problem.

    First, some theory:

    On the developer's machine:

    When you create an add-in with the add-in wizard, two .AddIn files are created:

    - One is named <MyAddIn>.AddIn and it is located in the folder of the add-in code. The only reason for this file is to have it in that folder along with the code of the add-in, so if you add your solution to source code control, it is added too. Or if you move the code to another folder, it is moved too. But this file is not used at all by the Add-In Manager of Visual Studio to recognize your add-in. Notice that the value  <Assembly> tag inside it specifies the name of the add-in dll without path (so it is wrong). This file is a kind of backup copy (but not synchronized with the actual .AddIn file). You can delete this file if you want, in fact, it is the best that you can do to avoid confusion.

    - Other is named <MyAddin - For Testing>.AddIn and it is located in a folder where Visual Studio looks for add-ins to show them in the Add-In Manager. This folder for VS 2008 is  <......>\My Documents\Visual Studio 2008\Addins". Notice that the value  <Assembly> tag inside it specifies the name of the add-in dll with path, which is correct. So, the add-in created by the add-in wizard just works. It stops working if you move the code of the add-in to another folder (so the output bin folder changes too) and you forget to adjust the path of the <Assembly> tag to the new path. In this case you get error 80070002 "The system cannot find the file specified".

    On the end user's machine:

    Your setup must ask the user the destination folder (typically a subfolder of "C:\Program Files"). Then the setup must create an .AddIn file in one of the folders where VS looks for .AddIn files and the setup must use some kind of custom action to modify the value of the <Assembly> tag to point to the destination folder selected by the user.

    Now, back to your problem:

    - Each time that you move the code of the add-in to a new folder, the output folder is changed too. If you don't adjust the <Assembly> tag of the .AddIn file in the \My Documents\Visual Studio 2008\Addins" folder, you get error 80070002 The system cannot find the file specified.

    - You are getting 80004005 instead because when the <Assembly> value doesn't specify a path and the dll is not in the same folder of the .AddIn file, you get that misleading error instead of 80070002 "The system cannot find the file specified", which is what VS should show. This is something new to me and I will update the my article to reflect this case. And why do you have an <Assembly> value without path? Because you copied the .AddIn file from the folder with the code of the add-in, and as I said, that .AddIn file doesn't specify the path in the <Assembly> value.

    Bottom line: open the .AddIn file of \My Documents\Visual Studio 2008\Addins" and set the proper value of <Assembly> with the correct path and dll name

    I hope it is clear now


    MZ-Tools: Productivity add-ins for Visual Studio: http://www.mztools.com. My blog about VS extensibility: http://msmvps.com/blogs/carlosq/
    • Proposed as answer by Carlos J. Quintero Wednesday, December 16, 2009 9:50 AM
    • Marked as answer by yeeen Wednesday, December 16, 2009 4:00 PM
    Wednesday, December 16, 2009 9:50 AM

All replies

  • See:

    HOWTO: Troubleshooting Visual Studio and Office add-ins
    http://www.mztools.com/resources_vsnet_addins.aspx

    and

    INFO: Default .AddIn file locations for Visual Studio add-ins
    (same link)

    and

    HOWTO: Create a setup for a Visual Studio 2005 / 2008 add-in using Inno Setup
    (same link)

    and

    http://blogs.msdn.com/craigskibo/archive/2007/05/03/making-add-in-development-easier.aspx
    MZ-Tools: Productivity add-ins for Visual Studio: http://www.mztools.com. My blog about VS extensibility: http://msmvps.com/blogs/carlosq/
    • Proposed as answer by Carlos J. Quintero Friday, October 23, 2009 11:50 AM
    • Marked as answer by Chao Kuo Wednesday, October 28, 2009 7:19 AM
    • Unmarked as answer by yeeen Wednesday, December 16, 2009 6:21 AM
    Friday, October 23, 2009 11:50 AM
  • As promised, I am back to follow up on this topic after I hv settled my other more urgent deadlines.
    Btw, I don't find the 3rd topic under the same link, but I found it from a google search.
    I am just starting to read ur articles, probably cos I am not so familiaze with VS, I am finding difficulties reading them.


    I reformatted my computer alr, now I only hv VS2008 (last time I hv both VS2005 n VS2008), but I am still running Windows XP.
    I can't run the previous add-in I created, so I copied the code to a new add-in project to make sure I can run it (cos it has been so long, I almost forgot I did). After that I moved the add-in project to another directory and delete the add-in file in the [...]\My Documents\Visual Studio 2008\Addins and copied the add-in file present in the project to the same directory. I cannot run the project anymore and I am able to simulate the same error now.

    I found the common problem with all the add-in projects that gives me this problem of a missing addin file (file with the exclamation mark):
    http://img25.imageshack.us/img25/5801/missingaddinfile.jpg (print screen)
    As mentioned above I alr added the add-in file back to the add-in folder, why would this file be missing?
    I double click on the file, it tells me it is looking for the file in "[...]\Addins" without this part: "\My Documents\Visual Studio 2008", which is rather puzzling.


    After regurgitate my problem in details, now I come to your articles.
    Right from the beginning, "HOWTO: Troubleshooting Visual Studio and Office add-ins" recommends me to read this page:
    "INFO: Default .AddIn file locations for Visual Studio add-ins" for "XML registration (Visual Studio 2005 and higher)"
    The info stated there is what I am supposed to changed for my VS? I don't quite understand, and I am afraid I changed the wrong things and everything goes haywire...

    "For Visual Studio add-ins, you can check if the add-in is registered through the Add-In Manager 
    ("Tools", "Add-In Manager"), which shows all registered add-ins
    (COM or XML, for all users or for the current user)."

    Yes, the add-in appears under my "Add-In Manager", this is because I have placed the add-in file in the Addins folder, the error appears when I check the box to select that add-in.


    Actually I just want my Addin project to be able to run in whichever directory and whichever computer I place it in. So I don't understand abt the troubleshooting process I am suppose to go through. Can u explain the significance? Thank you.

    • Edited by yeeen Wednesday, December 16, 2009 6:32 AM Updated!
    Wednesday, December 16, 2009 6:21 AM
  • To simulate the error msg I am having, download this file:
    http://www.mediafire.com/file/gxcztmjtjzy/MyTestingAddin.zip
    This is basically an addin project that does nothing but shows a message box with the message "Hello World!" when u click on Tools->MyTestingAddin

    For eg u saved it in the Deskstop, go to "[~]\Desktop\MyTestingAddin\MyTestingAddin",
    copy the "MyTestingAddin.AddIn" file to this folder "[~]\My Documents\Visual Studio 2008\Addins"

    If u open up this project, u will realise the file "MyTestingAddin -For Testing.Addin" missing.
    Go to Tools -> Add-in Manager, check the box "MyTestingAddin - No Name Provided", press OK.

    The error msg will now appear!

    (I tried before changing the addin file "MyTestingAddin.AddIn" to "MyTestingAddin -For Testing.Addin", it doesn't work too)
    Wednesday, December 16, 2009 7:08 AM
  • I have reproduced (and solved) your problem.

    First, some theory:

    On the developer's machine:

    When you create an add-in with the add-in wizard, two .AddIn files are created:

    - One is named <MyAddIn>.AddIn and it is located in the folder of the add-in code. The only reason for this file is to have it in that folder along with the code of the add-in, so if you add your solution to source code control, it is added too. Or if you move the code to another folder, it is moved too. But this file is not used at all by the Add-In Manager of Visual Studio to recognize your add-in. Notice that the value  <Assembly> tag inside it specifies the name of the add-in dll without path (so it is wrong). This file is a kind of backup copy (but not synchronized with the actual .AddIn file). You can delete this file if you want, in fact, it is the best that you can do to avoid confusion.

    - Other is named <MyAddin - For Testing>.AddIn and it is located in a folder where Visual Studio looks for add-ins to show them in the Add-In Manager. This folder for VS 2008 is  <......>\My Documents\Visual Studio 2008\Addins". Notice that the value  <Assembly> tag inside it specifies the name of the add-in dll with path, which is correct. So, the add-in created by the add-in wizard just works. It stops working if you move the code of the add-in to another folder (so the output bin folder changes too) and you forget to adjust the path of the <Assembly> tag to the new path. In this case you get error 80070002 "The system cannot find the file specified".

    On the end user's machine:

    Your setup must ask the user the destination folder (typically a subfolder of "C:\Program Files"). Then the setup must create an .AddIn file in one of the folders where VS looks for .AddIn files and the setup must use some kind of custom action to modify the value of the <Assembly> tag to point to the destination folder selected by the user.

    Now, back to your problem:

    - Each time that you move the code of the add-in to a new folder, the output folder is changed too. If you don't adjust the <Assembly> tag of the .AddIn file in the \My Documents\Visual Studio 2008\Addins" folder, you get error 80070002 The system cannot find the file specified.

    - You are getting 80004005 instead because when the <Assembly> value doesn't specify a path and the dll is not in the same folder of the .AddIn file, you get that misleading error instead of 80070002 "The system cannot find the file specified", which is what VS should show. This is something new to me and I will update the my article to reflect this case. And why do you have an <Assembly> value without path? Because you copied the .AddIn file from the folder with the code of the add-in, and as I said, that .AddIn file doesn't specify the path in the <Assembly> value.

    Bottom line: open the .AddIn file of \My Documents\Visual Studio 2008\Addins" and set the proper value of <Assembly> with the correct path and dll name

    I hope it is clear now


    MZ-Tools: Productivity add-ins for Visual Studio: http://www.mztools.com. My blog about VS extensibility: http://msmvps.com/blogs/carlosq/
    • Proposed as answer by Carlos J. Quintero Wednesday, December 16, 2009 9:50 AM
    • Marked as answer by yeeen Wednesday, December 16, 2009 4:00 PM
    Wednesday, December 16, 2009 9:50 AM
  • Thanks a lot :)
    Wednesday, December 16, 2009 4:00 PM