Excel-DNA / Excel-DNA/ExcelDna
FrameworkReference issue with xll (.NET 6)
- Dominant language
- C#
- Stars
- 1.5k
- Forks
- 292
- Avg merge
- 20d 12h
- Merged PRs (30d)
- 1
Description
I want to build a xll from a .csproj in .NET 6.
```
```
This xll depends on Microsoft.Extensions.Configuration because I want to read the .xll.config file.
The xll also transitively depends on FrameworkReference "Microsoft.AspNetCore.App" because of other mandatory stuff.
Now when packing the xll, I observes that Microsoft.Extensions.Configuration.dll and other needed dlls are not packed.
They are not copied in the output folder by MSBuild, this works as intended as the dlls are part of Microsoft.AspNetCore.App. I understand this is the reason of their absence in the packed xll.
Now, while trying to load the xll with Excel, I have this error :
```
ComAddIn [Error] The Ribbon/COM add-in helper required by add-in TestAddin Add-In could not be registered.
This may be due to the helper add-in being disabled by Excel.
To repair, open Disabled items in the Options->Add-Ins page and re-enable target add-in, then restart Excel.
Error details: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
--- End of inner exception stack trace ---
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at ExcelDna.Integration.ExcelComAddInHelper.LoadComAddIn(ExcelComAddIn addIn) : TargetInvocationException - Exception has been thrown by the target of an invocation.
```
I can confirm that if I get rid of the FrameworkReference, all the dlls are packed as intended and the xll loads successfully. But this is not my use case.
I tried to play with the runtimeconfig.json file but I did not manage to make it work.
My runtimeconfig.json file looks like below:
```{
"runtimeOptions": {
"tfm": "net6.0",
"rollForward": "LatestMinor",
"frameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "6.0.0"
},
{
"name": "Microsoft.AspNetCore.App",
"version": "6.0.0"
}
]
}
}
```
Could you tell me what I missed please?
Contributor guide
Assessment
This issue has not been assessed yet.