No object loaded when moving to net8

158 views
Skip to first unread message

Graeme Smith

unread,
Apr 1, 2025, 8:49:48 AM4/1/25
to Excel-DNA
Due to net6 being out of support, we have to move our addin (currently using net6.0-windows runtime and ExcelDna v1.70) to net8 (and thus ExcelDna v1.8.0).

We've updated all the csproj files, and updated the ExcelDna dependencies to 1.8.0.

On load, we now get the error message:
`Initialization [Error] No objects loaded from <x>, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null`

As far as I can tell, this happens before AutoOpen is called (at least, sticking a breakpoint inside AutoOpen didn't help).

AutoOpen code:
public void AutoOpen()
{
try
{
// As per https://groups.google.com/g/exceldna/c/lw_GTrGVxTY/m/slkXJVIHAwAJ
using var ctx = System.Runtime.Loader.AssemblyLoadContext.EnterContextualReflection(GetType().Assembly);

var sw = Stopwatch.StartNew();
Logger.Verbose("AutoOpen executing");
BsmCulture.SetAllCultureInfo();
var rval = ExcelError.ExcelErrorGettingData;

// Conversions for common parameter types
var paramConversionConfig = new ParameterConversionConfiguration()
.AddNullableConversion()
.AddParameterConversion(DisableOptionalArrays)
.AddReturnConversion(
(type, customAttributes) => type != typeof(object)
? null
: ((Expression<Func<object, object>>)
((object returnValue) => returnValue.Equals(ExcelError.ExcelErrorNA) ? rval : returnValue))
)
.AddParameterConversion(ParameterConversions.GetOptionalConversion(treatEmptyAsMissing: true));

var funcExecutionConfig = new FunctionExecutionConfiguration()
.AddFunctionExecutionHandler(CachedFunctionExecutionHandler.CacheHandler);

// This is required in order to use params: https://groups.google.com/forum/#!topic/exceldna/kf76nqAqDUo
ExcelRegistration
.GetExcelFunctions()
.ProcessAsyncRegistrations(nativeAsyncIfAvailable: false)
.ProcessParameterConversions(paramConversionConfig)
.ProcessParamsRegistrations()
.ProcessFunctionExecutionHandlers(funcExecutionConfig)
.RegisterFunctions();

IntelliSenseServer.Install();

// Customize return value for exceptions, as by default exceptions just return #VALUE.
ExcelIntegration.RegisterUnhandledExceptionHandler(e => ExceptionHandling.Handle((Exception) e));

MarketDataCenter.Init();

sw.Stop();
Logger.Verbose("AutoOpen complete in {AutoOpenDuration} seconds.", sw.ElapsedMilliseconds / 1000.0);
}

CsProj:
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<LangVersion>latest</LangVersion>
<RunExcelDnaPack>false</RunExcelDnaPack>
<UseWindowsForms>True</UseWindowsForms>
<SelfContained>false</SelfContained>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>

Dna File:
<DnaLibrary Name="<addin>- v99.99.99-pre" RuntimeVersion="v4.0">
<ExternalLibrary Path="
<addin>.dll" ExplicitRegistration="true" ExplicitExports="false" LoadFromBytes="true" />
<Reference Path="ExcelDna.Registration.dll" Pack="true" />
<Reference Path="ExcelDna.IntelliSense.dll" Pack="true" />

</DnaLibrary>

Is there anything obvious I've missed that would be causing this?

Thanks
Graeme

Govert van Drimmelen

unread,
Apr 1, 2025, 11:28:51 AM4/1/25
to exce...@googlegroups.com

Hi Graeme,

 

Can you try to build your project without the .dna file in the project dorectory?

Instead, just add the information as properties to the .csproj file

 

    <ExcelAddInExplicitExports>true</ExcelAddInExplicitExports>

 

 

The references for packing should be detected automatically.

 

-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/8b0cb0ae-f93c-4a9e-a79a-9a9181b845a7n%40googlegroups.com.

Message has been deleted

Graeme Smith

unread,
Apr 1, 2025, 11:41:55 AM4/1/25
to Excel-DNA
Thanks for the response

Have made that change, and the startup error is now:

First errors (one per function):
Initialization [Error] Method not registered - unsupported signature, abstract or generic: '<class>.<function>

Followed by (again, one per function):
Registration [Error] Repeated function name: '<function>' - previous registration will be overwritten. 

Govert van Drimmelen

unread,
Apr 1, 2025, 12:18:32 PM4/1/25
to exce...@googlegroups.com

Do you have the tag inside a PropertyGroup in the csproj file?

-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.

Graeme Smith

unread,
Apr 1, 2025, 2:16:58 PM4/1/25
to Excel-DNA
Yes, csproj below:

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

<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<LangVersion>latest</LangVersion>
<RunExcelDnaPack>false</RunExcelDnaPack>
<UseWindowsForms>True</UseWindowsForms>
<SelfContained>false</SelfContained>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>

<PropertyGroup>
<ExcelAddInExplicitExports>true</ExcelAddInExplicitExports>
</PropertyGroup>

Graeme Smith

unread,
Apr 1, 2025, 2:20:47 PM4/1/25
to Excel-DNA
Did a bit more digging, seems it's not *all* the functions that get the errors above, rather only the ones that return Task<string>

public static async Task<string> Function

Graeme Smith

unread,
Apr 1, 2025, 2:23:29 PM4/1/25
to Excel-DNA
Or rather, any function that returns Task<T> seems be throwing that error.

Other examples:
public static async Task<object> F2
public static async Task<object[,]> F3

Govert van Drimmelen

unread,
Apr 2, 2025, 3:12:47 AM4/2/25
to exce...@googlegroups.com

Sorry, I think you need to set ExcelDnaExplicitRegistration property. It switches off the automatic registration, when your own code is doing it.

-Govert


Graeme Smith

unread,
Apr 2, 2025, 3:33:09 AM4/2/25
to Excel-DNA
Thanks!

Added ExcelAddInExplicitRegistration
<PropertyGroup>
<ExcelAddInExplicitExports>true</ExcelAddInExplicitExports>
<ExcelAddInExplicitRegistration>true</ExcelAddInExplicitRegistration>
</PropertyGroup>

and it seems to now work (at least, it loads and the functions are all there, will kick the tyres properly today, but looking good so far).

Thanks again for the swift assistance.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages