VSTO Word Add-In No Longer Builds Successfully

John 0 Reputation points
2023-10-27T01:15:23.83+00:00

I have a Word add-in that I used to be able to build successfully but last week I've been unable to compile a successful build. Also the add-in installer used to work and now it doesn't. As a control test, I tried to create a new project with the Word VSTO Add-in template (.NET 7.7.2, 4.8, and 4.8.1, Any CPU, Word 2304, Visual Studio 17.7.6) and that also failed. Here's the error log:

System.IO.FileNotFoundException: Could not load file or assembly 'WordAddIn1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. File name: 'WordAddIn1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' ---> System.IO.FileNotFoundException: Could not load file or assembly 'WordAddIn1, Version=1.0.0.0, Culture=neutral' or one of its dependencies. The system cannot find the file specified.

Trimming the log because there appears to be an undocumented character limit on the site:

ERR: Failed to complete setup of assembly (hr = 0x80070002). Probing terminated. at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.Load(String assemblyString) at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.ExecuteCustomization.CreateEntryPoint(String entryPointTypeName) at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.ExecuteCustomization.Microsoft.VisualStudio.Tools.Office.Runtime.Interop.IExecuteCustomization2.LoadEntryPoints(IntPtr serviceProvider)

Word
Word
A family of Microsoft word processing software products for creating web, email, and print documents.
895 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,260 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Zhengye Xu-MSFT 95 Reputation points Microsoft Vendor
    2023-10-27T06:39:41.5066667+00:00

    Hi John,

    Welcome to Microsoft Q&A forum.

    I suggest you recreate a Word VSTO Add-In project and build it to determine if the problem only occurs in a specific project.

    If the issue only occurs in a specific project, you can try cleaning up the build of that project and rebuilding. You can try the following methods:

    1.       Close Visual Studio, open the project folder, delete .vs and all bin/obj directories, and then reopen Visual Studio to build. If you don't see the .vs folder under the project folder, you need to check the hidden items in the view settings to make it visible.

    2.       Clean up the nuget package. Turn to Main menu>Tools>Options>Nuget package management and click clear all nuget storage.

    3.       Open the project folder to find the assemblies referenced by the project and compare them to the referenced assemblies in Visual Studio to check for missing assemblies. You can also reinstall your assemblies in Visual Studio to avoid missing assemblies.

    If the problem exists in other projects, then your Visual Studio may have an error. Try repairing Visual Studio using the Visual Studio installer.

    Best Regards,

    Zhengye


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. John 0 Reputation points
    2023-11-06T20:56:21.16+00:00

    So it looks like what happened was our Sysmon was blocking the dlls.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.