Location of dlls and other files when a VSTO AddIn project is built in Visual Studio RRS feed

  • Question

  • As explained in this MSDN tutorial, when you run/build an MS Word VSTO project in Visual Studio, it creates your custom office Word AddIn in Word application. You can later remove that AddIn using VS, as explained in the last section of the above mentioned MSDN tutorial, as follows:

    Cleaning up the Project

    When you finish developing a project, remove the VSTO Add-in assembly, registry entries, and security settings from your development computer. Otherwise, the VSTO Add-in will continue to run every time that you open Word on your development computer.

    To clean up the completed project on your development computer

    1. In Visual Studio, on the Build menu, click Clean Solution.

    My Question: When custom AddIn is created (as explained in the above MSDN tutorial) where are the corresponding dlls, and other related files (data files etc) from AddIn project get deployed?

    • Edited by namwam Sunday, December 18, 2016 5:39 PM
    Sunday, December 18, 2016 5:39 PM

All replies

  • The files are in the regular bin folder of your solution. The location can be set in the project options (Build | Output Path).  Uninstalling an addin simply removes the HKCU\SOFTWARE\Microsoft\Office\Word\Addins entry fror your addin and the COM registry keys corresponding to the COM object exposed by your addin and custom task panes.

    Dmitry Streblechenko (MVP)
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Sunday, December 18, 2016 6:09 PM
  • Dmitry,

    I've (Build | Output Path) set as shown below:

    Likewise, in my custom Ribbon, one button's callback function is saving Active Word document As testFile.txt in the code shown below. This file's property in VS is set as follows:

    But this code works fine when I'm in a debug mode (click F5) in VS project and click on my custom Ribbon's Button. However, I get the error shown below when, in VS-2015, I click on "Rebuild Project" and open a Word document and click on my custom Ribbon's same button.

    Portion of Custom Ribbon's Button's Callback funtion:

    string sTeXFileName = Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory())) + "\\testFile.txt";
    oActiveDoc.SaveAs2(FileName: sTeXFileName, FileFormat: Word.WdSaveFormat.wdFormatText);

    Error in above code after project is built and Button in Custom Ribbon is clicked:

    Word cannot save or create this file. Make sure that the disk you want to save the file on is not full, write-protected or damaged. File: c:\Users\testFile.txt

    It seems the above code finds the test.txt file correctly when AddIn is in VS's debug mode (when you click F5). But after the project is built (and AddIn is created in Word), the above code looks for test.txt file in c:\Users folder instead of project's bin\Debug folder. Please note that this does not happen if we create a regular Winform project that access's a file. In that case the above code would access the file from bin\Debug folder after project is  built  - with the properties set as explained above. But that is not happening in a VSTO project case.

    • Edited by namwam Sunday, December 18, 2016 9:39 PM
    Sunday, December 18, 2016 7:53 PM
  • Hi namwam,

    I can see that you are using oActiveDoc.SaveAs2 method.

    did you try to use only saveAs method?

    if not then try to test with that and let us know if you get same error with that too.

    both method saves the file in same condition mentioned below.

    The name for the document. The default is the current folder and file name. If the document has never been saved, the default name is used (for example, Doc1.doc). If a document with the specified file name already exists, the document is overwritten without prompting the user.


    Document.SaveAs Method

    Document.SaveAs2 Method (Word)



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Monday, December 19, 2016 7:11 AM
  • Why do you assume GetCurrentDirectory() will point to a particular location? It can be any folder. Why not save in the user's Documents default folder?

    Dmitry Streblechenko (MVP)
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Monday, December 19, 2016 3:37 PM