Trouble loading add-in targeting .NET 9 – "System.Runtime, Version=9.0.0.0" error

72 views
Skip to first unread message

Lucas Melo

unread,
Jul 12, 2025, 11:31:02 AMJul 12
to Excel-DNA

Hi everyone,

I'm relatively new to .NET and Excel-DNA, and I'm trying to build an add-in targeting .NET 9.0 using the latest Excel-DNA v1.9.0-beta2.

The build process seems to work fine — the .dll and .xll files are generated correctly in the Debug folder of my UserInterface project. However, when I try to load the .xll in Excel, I get this error:

Could not load file or assembly 'System.Runtime, Version=9.0.0.0... The system cannot find the file specified.'

To troubleshoot this, I have already:

  • Installed the latest .NET 9.0 Desktop Runtime (Preview) (confirmed via dotnet --list-runtimes)

  • Ensured my .csproj is targeting net9.0-windows

  • Verified the .xll is being generated and properly references the main library via the .dna file

Despite that, the error persists.
I'm unsure if I'm missing something specific when targeting a preview version of .NET or if additional configuration is required in Excel-DNA for it to recognize the runtime correctly.

Has anyone successfully run an Excel-DNA add-in using .NET 9?
Any guidance or checklist would be greatly appreciated!

Thanks in advance.

Govert van Drimmelen

unread,
Jul 12, 2025, 2:57:28 PMJul 12
to Excel-DNA
Hi Lucas,

There should be no problem targeting .NET 9 with that Excel-DNA version.

Can you confirm whether you have a .dna file in your project (input) directory?
If so, that can cause trouble. It's better if you don't have a separate .dna file that you manage - it is generated at compile time into the output directory.

If that's not the problem, have you tried making a new project with a minimal .csproj file and code:

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

  <PropertyGroup>
    <TargetFramework>net9.0-windows</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="ExcelDna.AddIn" Version="1.9.0-beta2" />
  </ItemGroup>

</Project>

```
using ExcelDna.Integration;

namespace TestNet9
{
    public static class MyFunctions
    {
        [ExcelFunction(Description = "My first .NET function")]
        public static string SayHello(string name)
        {
            return "Hello " + name;
        }
    }
}
```

That _should_ work fine.

-Govert

Lucas Melo

unread,
Jul 16, 2025, 7:41:52 AMJul 16
to exce...@googlegroups.com

Hi Govert,

Thank you very much, you were absolutely right.
I was manually creating a .dna file in the input directory, following a "tutorial", which was indeed causing the issue.

After removing it and relying on the auto-generated one, everything is working perfectly.

Really appreciate your help and the amazing work on Excel-DNA!

Best regards,
Lucas


--
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/8840702d-5b3c-43d6-a9d6-c8bda0b06337n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages