Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Assembly binding error when building Office add-in: "FindRibbons" task failed unexpectedly

We're trying to set up a Jenkins (build server) job to build our Office add-in based on VSTO. However, I keep getting a strange error that fails the build process after the DLL is copied to the bin directory of the project:

Error 11 The "FindRibbons" task failed unexpectedly.
System.IO.FileNotFoundException:
  Could not load file or assembly 'MyAddIn, Version=1.0.0.0, Culture=neutral, 
  PublicKeyToken=null' or one of its dependencies.
  The system cannot find the file specified.
File name: 'MyAddIn, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'

So the problem is that the "FindRibbons" task, triggered by the Office add-in build target, has successfully identified the MyAddIn DLL as being an Office Add-In, but is not able to locate and load it!

Any ideas? I'd love to be able to debug the FindRibbons task directly but hooking into and debugging the compile process seems a little extreme...


Here are some observations:

  • In our build server's Fusion logs for binding the MyAddIn assembly it looks like it's looking in the folder where MSBuild.exe lives (C:\Windows\Microsoft.NET\Framework\v4.0.30319\) and nowhere else. On my dev machine, there is no Fusion log entry for MyAddIn! But the build process succeeds and Kivo works fine.
  • On both my dev and build machines I also have Fusion log entries for WhereRefBind!Host=(LocalMachine)!FileName=(PresentationCore.dll) and ExplicitBind!FileName=(MyAddIn.dll) which show the binding succeeding.
  • This error comes up on the build server whether I use Visual Studio or MSBuild from the command line to build the project.
  • I've ensured that the .NET/MSBuild/VS2012 versions are identical on both my dev machine and the build server and the error still occurs. The only difference seems to be that the build server is running Windows Server 2012 (since it's Azure, and we can't spin up a Windows 7 image).
like image 404
rhodri Avatar asked Nov 26 '13 14:11

rhodri


3 Answers

This has worked for me every time I upgrade Visual Studio - I don't use ribbons.

This worked for my solution, but use at your own risk:

  1. Open the following file in an XML editor (make a backup first): C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets (the v10.0 part may be different for you, e.g., it might be v14.0)

  2. Remove the following section:

    <FindRibbons AssemblyName="$(AbsolutePathToCustomization)" TargetFramework="$(TargetFrameworkVersion)">
        <Output TaskParameter="RibbonTypes" ItemName="RibbonTypesCollection"/>
    </FindRibbons> 
    
  3. Replace all occurrences of "@(RibbonTypesCollection)" with the empty string ""

  4. Save the file and restart the visual studio

like image 199
Dan Rasmussen Avatar answered Nov 08 '22 09:11

Dan Rasmussen


If you migrated the project from a previous version of Visual Studio, be sure to remove the ExcelLocale1033 and SecurityTransparent attributes from the AssemblyInfo.cs file (as answered by Swati in this other question)

If the project still fails to build, it may be because your .csproj file has some references to msbuild's tasks of previous versions of Visual Studio. I suggest you to create a new empty Excel AddIn project, and uses the msbuild structure of the new project file as base for your project.

like image 8
Gustavo Russo Avatar answered Nov 08 '22 07:11

Gustavo Russo


I had this problem. It was apparently caused because I changed the "Copy Local" setting on reference "Microsoft.Office.Tools.Common.v4.0.Utilities" from True to False. ISYN. (I sh*t you not)

I had upgraded a project from VS2012 to VS2013 and noticed that that reference was the only one set to "Copy Local = True". So I set it to false, because it was different. This caused the error. Changing it back to True solved it.

like image 8
RokShox Avatar answered Nov 08 '22 07:11

RokShox