Error message "!!! ERROR: ExternalLibrary `%OutputFileName%` not found. ABORTING."

71 views
Skip to first unread message

Albrecht Hilmes

unread,
Jul 2, 2025, 8:41:58 AMJul 2
to Excel-DNA
This is my environment:
   -   Operating system: Windows 11
   -   Excel Microsoft 365 apps for business (64-bit)
   -   Visual Studio Community 2022 (64-bit)
   -   .NET Framework 4.7.2
   -   ExcelDna.AddIn 1.8.0
   -   ExcelDna.Integration 1.8.0

I started a normal project from scratch:

1. Create a new project
2. Class Library (.NET Framework)
3. Project name: "ClassLibrary1", Solution Name: "ClassLibrary1" (.NET Framework 4.7.2)
4. Press Button "Create"
5. Menu -> Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution...
6. Install ExcelDna.AddIn (1.8.0)
7. Remark: ExcelDna.Integration will be installed automatically during step 6
8. Menu -> Build -> Build Solution now already generates this error message

!!! ERROR: ExternalLibrary `%OutputFileName%` not found. ABORTING.

System.InvalidOperationException: !!! ERROR: ExternalLibrary `%OutputFileName%` not found. ABORTING.
   at ExcelDna.PackedResources.ExcelDnaPack.PackDnaLibrary(String dnaPath, Byte[] dnaContent, String dnaDirectory, ResourceUpdater ru, Boolean compress, Boolean multithreading, List`1 filesToPublish, Boolean packManagedDependencies, String[] dependenciesToExcludeParam, String outputBitness, IBuildLogger buildLogger)
   at ExcelDna.PackedResources.ExcelDnaPack.Pack(String dnaPath, String xllOutputPathParam, Boolean compress, Boolean multithreading, Boolean overwrite, String usageInfo, List`1 filesToPublish, Boolean packNativeLibraryDependencies, Boolean packManagedDependencies, String excludeDependencies, Boolean useManagedResourceResolver, String outputBitness, IBuildLogger buildLogger)
   at ExcelDna.AddIn.Tasks.PackExcelAddIn.Execute()

9. Nothing changes in the error message if I create a small function like this:

namespace ClassLibrary1
{
    public static class Class1
    {
        public static double TestFormula(double x)
        {
            return x + x;
        }
    }
}

Govert van Drimmelen

unread,
Jul 2, 2025, 6:56:34 PMJul 2
to Excel-DNA

Hi Albrecht,

I follow the same steps, and everything works fine for me. I have Windows 10 and VS Pro, but don't think that makes a difference. What I think happened is that a small install script in the ExcelDna.AddIn NuGet package was supposed to run but maybe did not. That left you with a file called something like ExcelDna-Template.dna which should have been renamed and had some template entries that should be filled in. It is causing the errors you see. I don't know why the install script did not run for you.

Better would be to make a new project using the "Class Library" option rather than "Class Library (.NET Framework)". Choose any .NET version in the wizard - we'll change to .NET Framework 4.7.2 in the project file afterwards. Once you have the project, replace everything in the .csproj file so that it looks like this:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net472</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="ExcelDna.AddIn" Version="1.8.0" />
  </ItemGroup>
 
</Project>

With a new project and this project file, you can then add a function, compile and run. Everything should work fine.

I will try to explain more detail.

With .NET there are old-style project files, and SDK-style project files. When you make a library with “Class Library (.NET Framework)” you get an old-style project file. When you make a library with “Class Library” you get an SDK-style project file. By default the SDK-style project file wizard is set up to target .NET Core (some version of .NET 5+), but you can also target .NET Framework (e.g., .NET Framework 4.7.2) from an SDK-style project. SDK-style project files are better, and you should use them whether you target .NET Framework 4.x or .NET 5+ (aka .NET Core). Existing projects that use old-style project files should be converted to SDK-style project files, but that can be a bit tricky.

(To be clear, targeting .NET Framework 4.x with your Excel-DNA add-in is a good idea - there are many benefits to using the stable .NET Framework rather than the new .NET core runtimes which change often. This discussion is just about which type of project file to use for building your projects. Newer SDK-style files can target both runtime generations.)

When using old-style project files, there are two styles of managing the NuGet packages: a packages.config file or with <PackageReference> entries in the proejct file. With SDK-style project files you would only use <PackageReference> entries - you can add the packages with the VS interface or by editing the .csproj file directly.

The ExcelDna.AddIn package supports both old-style project files and SDK-style, and supports both packages.config and <PackageReference> style NuGet references. When installing the ExcelDna.AddIn package into a project that uses packages.config (or with no packages, while the Visual Studio default setting is to create a packages.config file instead of <PackageReference> entries) then the ExcelDna.AddIn package runs a small install script after being added to the project. I can see that the script runs by looking in the "Package Manager" view of the Output window. I see the following:

Attempting to gather dependency information for package 'ExcelDna.AddIn.1.8.0' with respect to project 'ClassLibrary3', targeting '.NETFramework,Version=v4.7.2'
Gathering dependency information took 444 ms
Attempting to resolve dependencies for package 'ExcelDna.AddIn.1.8.0' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'ExcelDna.AddIn.1.8.0'
Resolved actions to install package 'ExcelDna.AddIn.1.8.0'
Adding package 'ExcelDna.Integration.1.8.0' to folder 'C:\Temp\ClassLibrary3\packages'
Added package 'ExcelDna.Integration.1.8.0' to folder 'C:\Temp\ClassLibrary3\packages'
Added package 'ExcelDna.Integration.1.8.0' to 'packages.config'
Successfully installed 'ExcelDna.Integration 1.8.0' to ClassLibrary3
Adding package 'ExcelDna.AddIn.1.8.0' to folder 'C:\Temp\ClassLibrary3\packages'
Added package 'ExcelDna.AddIn.1.8.0' to folder 'C:\Temp\ClassLibrary3\packages'
Added package 'ExcelDna.AddIn.1.8.0' to 'packages.config'
Executing script file 'C:\Temp\ClassLibrary3\packages\ExcelDna.AddIn.1.8.0\tools\net452\install.ps1'...
Starting ExcelDna.AddIn install script
Creating -AddIn.dna file
Completed ExcelDna.AddIn install script

Successfully installed 'ExcelDna.AddIn 1.8.0' to ClassLibrary3
Executing nuget actions took 1.8 sec
Time Elapsed: 00:00:02.6373593
========== Finished ==========

That install script did not run on your machine, for some reason.

Anyway, I suggest you use SDK-style project files instead, avoiding all the trouble.

Please write back if you still have problems getting the project started, or run into any other problems with your add-in.

Regards,
Govert

Albrecht Hilmes

unread,
Jul 3, 2025, 3:12:00 AMJul 3
to Excel-DNA
Thank you Govert, 
starting with a .NET 8.0 framework and and then switching to a 4.7.2 has worked well.
The target .NET framework 4.7.2 does not appear in the dropdown of VS-project settings and can only be changed in the *.csproj by editor.

Best regards
Albrecht

Albrecht Hilmes

unread,
Jul 4, 2025, 7:35:47 AMJul 4
to Excel-DNA
Is there a suitable example in C# for creating a ribbon for this project type?

Govert van Drimmelen

unread,
Jul 4, 2025, 12:18:23 PMJul 4
to Excel-DNA
Hi Albrect,


-Govert

Albrecht Hilmes

unread,
Jul 9, 2025, 4:02:57 AMJul 9
to Excel-DNA
All works well now. -Thank you, Govert!
However, it is worth mentioning that you have to add images and XML-files to the resx file with the legacy managed resource editor.
Furthermore: Is it possible to start a "ribbon-procedure" (void DoSomething(IRibbonControl control)) also directly from excel?
e.g. in an VBA-sub or with "start macro"?
Or is it possible to react to a keystroke (e.g. F5)?

Govert van Drimmelen

unread,
Jul 9, 2025, 4:49:10 AMJul 9
to exce...@googlegroups.com

Hi Albrecht,

 

Please start a new discussion for new questions – that helps future me and others find the relevant topic more easily.

 

It’s not easy to call the ribbon procedure from VBA.

But you can define and register macro commands in your add-in like this

        [ExcelCommand(ShortCut ="{F5}")]   // Or something like "^w" to mean Ctrl + w

        public static void DoTheWork()

        {

            var app = ExcelDnaUtil.Application as Application;

            app.ActiveSheet.Range["A1"].Value = "Hello from a command!";

        }

 

Such a macro can be:

  • Run from VBA with Application.Run("DoTheWork") and
  • Called directly from other code in your add-in (as a normal C# method), in particular from the ribbon callback too.
  • You can also type the name of the macro into the “Macros” dialog box that you get from pressing Alt + F8 – the macro command is not listed there since macros from xll add-ins are always considered “hidden”. But when you type the full name, the “Run” button becomes enabled and you can execute the macro.
  • Set as the ‘Assign Macro’ for a button that you insert on a sheet.

 

You can directly add a shortcut to the ExcelCommand definition, as above, but sometimes you cannot override the built-in shortcuts this way, so "^c" (Ctrl + C) won’t work.

 

-Govert

--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/exceldna/d25c05fc-7512-423a-9466-d1efd53e1e9en%40googlegroups.com.

Albrecht Hilmes

unread,
Jul 9, 2025, 5:03:25 AMJul 9
to Excel-DNA
Reply all
Reply to author
Forward
0 new messages