Trap error while loading addin

107 views
Skip to first unread message

Krishna Kumar

unread,
Jul 12, 2023, 12:13:46 PM7/12/23
to Excel-DNA
Hi,

I am using .Net 6 to create an addin for Excel. I started with a simple Hello World addin using Visual Studio 2022 but it was not loading the ExcelFunction in Excel. I could not see any error. After lot of trial and updating Visual Studio to latest version resolved the issue. I was able to use Hello World function successfully.
Then I created an addin to load data from Redis into Excel. It was working on my machine but when I provided the addin to other people they were not able to see the methods. There was no error thrown when loading the addin via Options -> Manage Addin
I assumed it must be .Net 6 runtime so I first copied .NET Runtime 6.0.19 binaries from https://dotnet.microsoft.com/en-us/download/dotnet/6.0 and added DOTNET_ROOT but that dint help. Then I tried SDK binaries and updated DOTNET_ROOT and that fixed it. 

My questions are -
1. Do we need .NET Runtime or .NET Desktop Runtime or SDK installed on User's machine?
2. Do we need to add any environment variable? Some of the users had Dot Net 6 installed but I could not get the addin working without adding DOTNET_ROOT env variable.
3. How do we trap errors when loading the addin? One of the biggest frustration was no error was thrown when adding the addin. I know we can add logging to ExcelDna to capture errors when something wrong with the ExcelFunction but how do I trap error in the log when loading addin has not worked. 

Govert van Drimmelen

unread,
Jul 12, 2023, 1:28:15 PM7/12/23
to exce...@googlegroups.com

--------------------------------------------------
Excel-DNA is now registered on 
GitHub Sponsors.
Your small monthly contribution will directly fund further development.
--------------------------------------------------

 

Hi Krishna,

 

I think you need the “.NET 6 Desktop Runtime” installed on the client. I don’t think the plain .NET Runtime is enough.

This also needs to be the 32-bit or 64-bit version that matches your Excel installation.

We try to check for errors at startup and give a sensible message, I’m pretty sure this works if there is no .NET 6 runtime installed.

But there might be some extra cases, like if the plain runtime is installed, but not the “Desktop Runtime”.

I’ve added an issue on Github to review this a bit - Review startup error handling · Issue #627 · Excel-DNA/ExcelDna (github.com)

 

What version of Excel-DNA are you checking?

I think the latest pre-release versions 1.7.0-rc4 are better at this than version 1.6.

 

I should add that this was an aspect of .NET 6 that is not great, and Microsoft have improved a bit for .NET 7 (though that does not help us, at least you can see the considerations). See here: Improving .NET host error messages and supportability - .NET Blog (microsoft.com)

 

To answer your questions:

  1. .NET 6 Desktop Runtime (definitely don’t need SDK).
  2. Not with a default install of the runtime (maybe the installer sets the variables?) But if you just copy and extract the runtime files, you might need to set such a variable. In this regard we’re not doing anything special- we load the runtime using the default suggested mechanism (nethost.dll).
  3. Typically you can’t handle runtime loading errors, because none of your code ever runs. We need to identify scenarios that are problematic and handle better in the Excel-DNA loader. But this is difficult work (need to set up VMs with different runtime configurations, for example). So it’s likely to improve slowly. Unless you have some suggestions.

 

-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 on the web visit https://groups.google.com/d/msgid/exceldna/a71a5974-fc9c-4282-8561-144acf576f30n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages