When I built my Windows desktop C# project, I encountered some failures related to ExcelDna.AddIn (error DNA-818471385). Here is the sample error message.
107>MSBUILD : PackExcelAddIn error DNA-818471385: Assembly at bin\Debug\net8.0-windows\Microsoft.Bcl.AsyncInterfaces.dll could not be packed. Possibly a mixed assembly? (These are not supported yet.) 107>MSBUILD : PackExcelAddIn error DNA-818471385: Exception: System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. Cannot specify assembly evidence under MultiDomain after non-GAC assemblies with default evidence have been loaded in appdomain. (Exception from HRESULT: 0x8013101D) 107>MSBUILD : PackExcelAddIn error DNA-818471385: File name: 'Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' ---> System.Runtime.InteropServices.COMException (0x8013101D): Cannot specify assembly evidence under MultiDomain after non-GAC assemblies with default evidence have been loaded in appdomain. (Exception from HRESULT: 0x8013101D) 107>MSBUILD : PackExcelAddIn error DNA-818471385: at System.Reflection.RuntimeAssembly.nLoadImage(Byte[] rawAssembly, Byte[] rawSymbolStore, Evidence evidence, StackCrawlMark& stackMark, Boolean fIntrospection, Boolean fSkipIntegrityCheck, SecurityContextSource securityContextSource) 107>MSBUILD : PackExcelAddIn error DNA-818471385: at System.Reflection.Assembly.Load(Byte[] rawAssembly) 107>MSBUILD : PackExcelAddIn error DNA-818471385: at ResourceHelper.ResourceUpdater.AddAssembly(String path, String source, Boolean compress, Boolean multithreading, Boolean includePdb) 107>MSBUILD : PackExcelAddIn error DNA-818471385: 107>MSBUILD : PackExcelAddIn error DNA-818471385:
Solution
Add reference "Microsoft.Bcl.AsyncInterfaces" on project that have ExcelDna.AddIn reference like this sample csproj below
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net8.0-windows</TargetFramework> <ImplicitUsings>enable</ImplicitUsings> <Nullable>enable</Nullable> <EnableDynamicLoading>true</EnableDynamicLoading> </PropertyGroup> <ItemGroup> <PackageReference Include="ExcelDna.AddIn" Version="1.8.0" /> <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" /> <PackageReference Include="dsinvs.Service.Impl" Version="3.2.1" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\invest-service\dsinvs.Common.Win32.Standard\dsinvs.Common.Win32.Standard.csproj" /> <ProjectReference Include="..\invest-service\dsinvs.Invest.Trade.RT.Service\dsinvs.Invest.Trade.RT.Service.Standard.csproj" /> </ItemGroup> <ItemGroup> <Reference Include="Microsoft.Office.Interop.Excel"> <HintPath>C:\Program Files (x86)\Microsoft Visual Studio\Shared\Visual Studio Tools for Office\PIA\Office15\Microsoft.Office.Interop.Excel.dll</HintPath> <Private>True</Private> <EmbedInteropTypes>True</EmbedInteropTypes> </Reference> </ItemGroup> </Project>
Discover more from naiwaen@DebuggingSoft
Subscribe to get the latest posts sent to your email.