Hi there !
I'm creating a simple (let's call it MyAddin), I pack it using ExcelDnaPack.exe, and I'm able to use this addin by double clicking the MyAddin-packed.xll. So far so good.
Now, for further work, I need to use another lib for this addin (let's call it SomeTool).
I have the file SomeTool.nupkg in my project folder, and I register it as a reference package in my .csproj :
<ItemGroup>
<PackageReference Include="SomeTool" Version="1.0.4" />
</ItemGroup>
The thing is, SomeTool comes with its own dependencies, namely:
- Microsoft.Extensions.DependencyInjection.Abstractions.dll
- Microsoft.Extensions.DependencyInjection.dll
- Microsoft.Extensions.Logging.Abstractions.dll
- Microsoft.Extensions.Logging.dll
- Microsoft.Extensions.Options.dll
- Microsoft.Extensions.Primitives.dll
And in order for my addin to work properly locally, I need to copy/paste all those DLLs into the output folder, next to MyAddin.dll, MyAddin-Addin64.dna, and MyAddin-Addin64.xll. And that works.
The problem is that I would like to pack all those dependencies with the rest into
MyAddin-packed.xll (as it seems to be the case for ExcelDna.Integration.dll), so it is easier to distribute to the users.
To that end, I added this to the
.dna file:
<ExternalLibrary Path="MyAddin.dll" Pack="true" />
<!-- Those extra lines : -->
<ExternalLibrary Path="Microsoft.Extensions.DependencyInjection.Abstractions.dll" Pack="true" />
<ExternalLibrary Path="Microsoft.Extensions.DependencyInjection.dll" Pack="true" />
<ExternalLibrary Path="Microsoft.Extensions.Logging.Abstractions.dll" Pack="true" />
<ExternalLibrary Path="Microsoft.Extensions.Logging.dll" Pack="true"/>
<ExternalLibrary Path="Microsoft.Extensions.Options.dll" Pack="true"/>
<ExternalLibrary Path="Microsoft.Extensions.Primitives.dll" Pack="true"/>
<ExternalLibrary Path="SomeTool.dll" Pack="true" />
And the packing seems to be ok:
7>PackProgram: Using base add-in ...\MyAddin.xll
7>PackProgram: ~~> ExternalLibrary path
MyAddin .dll resolved to ...\
MyAddin .dll.
7>PackProgram: ~~> ExternalLibrary path Microsoft.Extensions.DependencyInjection.Abstractions.dll resolved to ...\bin\x64\Debug\net8.0-windows\Microsoft.Extensions.DependencyInjection.Abstractions.dll.
7>PackProgram: ~~> ExternalLibrary path Microsoft.Extensions.DependencyInjection.dll resolved to ...\bin\x64\Debug\net8.0-windows\Microsoft.Extensions.DependencyInjection.dll.
7>PackProgram: ~~> ExternalLibrary path Microsoft.Extensions.Logging.Abstractions.dll resolved to ...\bin\x64\Debug\net8.0-windows\Microsoft.Extensions.Logging.Abstractions.dll.
7>PackProgram: ~~> ExternalLibrary path Microsoft.Extensions.Logging.dll resolved to ...\bin\x64\Debug\net8.0-windows\Microsoft.Extensions.Logging.dll.
7>PackProgram: ~~> ExternalLibrary path Microsoft.Extensions.Options.dll resolved to ...\bin\x64\Debug\net8.0-windows\Microsoft.Extensions.Options.dll.
7>PackProgram: ~~> ExternalLibrary path Microsoft.Extensions.Primitives.dll resolved to ...\bin\x64\Debug\net8.0-windows\Microsoft.Extensions.Primitives.dll.
7>PackProgram: ~~> ExternalLibrary path Office.dll resolved to ...\bin\x64\Debug\net8.0-windows\Office.dll.
7>PackProgram: ~~> ExternalLibrary path SomeTool.dll resolved to ...\bin\x64\Debug\net8.0-windows\MidwayClientSuiteLibraryDotNet.dll.
7>PackProgram: -> Updating resource: Type: DNA, Name: __MAIN__, Length: 3282
7>PackProgram: -> Updating resource: Type: ASSEMBLY_LZMA, Name: MICROSOFT.EXTENSIONS.PRIMITIVES, Length: 19908
7>PackProgram: -> Updating resource: Type: ASSEMBLY_LZMA, Name: MICROSOFT.EXTENSIONS.LOGGING, Length: 22875
7>PackProgram: -> Updating resource: Type: ASSEMBLY_LZMA, Name: SOMETOOL, Length: 14984
7>PackProgram: -> Updating resource: Type: ASSEMBLY_LZMA, Name: MYADDIN, Length: 17272
7>PackProgram: -> Updating resource: Type: ASSEMBLY_LZMA, Name: MICROSOFT.EXTENSIONS.DEPENDENCYINJECTION.ABSTRACTIONS, Length: 24809
7>PackProgram: -> Updating resource: Type: ASSEMBLY_LZMA, Name: MICROSOFT.EXTENSIONS.OPTIONS, Length: 25655
7>PackProgram: -> Updating resource: Type: ASSEMBLY_LZMA, Name: MICROSOFT.EXTENSIONS.LOGGING.ABSTRACTIONS, Length: 26174
7>PackProgram: -> Updating resource: Type: ASSEMBLY_LZMA, Name: MICROSOFT.EXTENSIONS.DEPENDENCYINJECTION, Length: 37365
7>PackProgram: -> Updating resource: Type: ASSEMBLY_LZMA, Name: OFFICE, Length: 95642
7>PackProgram: Completed Packing
But then when running the addin I get this on start :
Initialization [Error] No objects loaded from Microsoft.Extensions.DependencyInjection, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
Initialization [Error] No objects loaded from Microsoft.Extensions.Logging.Abstractions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
Initialization [Error] No objects loaded from Microsoft.Extensions.Logging, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
Initialization [Error] No objects loaded from Microsoft.Extensions.Options, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
Initialization [Error] No objects loaded from Microsoft.Extensions.Primitives, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
Initialization [Error] No objects loaded from office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c
Initialization [Error] No objects loaded from SomeTool, Version=1.0.4.0, Culture=neutral, PublicKeyToken=null
(Interesting to note that Microsoft.Extensions.DependencyInjection.Abstractions is the only one not causing errors).
And of course the addin doesn't work (the extra tab on the ribbon won't even show).
What am I doing wrong/forgetting here ?
Thanks ! ^_^