Intellisense AutoOpen Error

131 views
Skip to first unread message

László Sleisz

unread,
Apr 2, 2025, 5:16:59 AM4/2/25
to Excel-DNA
Hello,

I get an error messages, when I open the …….-AddIn-packed.xll. The IntelliSense works fine, when I open the Excel from the Visual Studio.

Initialization [Warning] Assembly EXCELDNA.INTELLISENSE could not be loaded from resources.
Initialization [Error] DnaLibrary AutoOpen Invoke Error : FileNotFoundException - A(z) „ExcelDna.IntelliSense, Version=1.1.0.0, Culture=neutral, PublicKeyToken=f225e9659857edbe” fájl vagy szerelvény, illetve annak egyik függősége nem tölthető be. A rendszer nem találja a megadott fájlt.


I use:
- VS 2022 with C#
- Excel 2016
- .Net Framework 4.6.2
- ExcelDna.AddIn 1.8.0
- ExcelDna.Integration 1.8.0
- ExcelDna.IntelliSense 1.8.0

InteliSense.cs:

using ExcelDna.Integration;
using ExcelDna.IntelliSense;

public class IntelliSenseAddIn : IExcelAddIn
{
    public IntelliSenseAddIn()
    {
    }

    public void AutoOpen()
    {
        IntelliSenseServer.Install();
    }
    public void AutoClose()
    {
        IntelliSenseServer.Uninstall();
    }
}


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

  <PropertyGroup>
    <TargetFramework>net4.6.2-windows</TargetFramework>
<LangVersion>8.0</LangVersion>
   
    <Nullable>enable</Nullable>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="ExcelDna.Addin" Version="1.8.0" />
    <PackageReference Include="ExcelDna.Integration" Version="1.8.0" />
  </ItemGroup>
  <ItemGroup>
<PackageReference Include="ExcelDna.IntelliSense" Version="1.8.0" />
  </ItemGroup>
  <ItemGroup>
    <Reference Include="ExcelDna.IntelliSense">
      <HintPath>bin\Debug\net4.6.2-windows\ExcelDna.IntelliSense.dll</HintPath>
    </Reference>
  </ItemGroup>

</Project>

Thanks

Govert van Drimmelen

unread,
Apr 2, 2025, 5:22:06 AM4/2/25
to Excel-DNA
When targeting .NET Framework (as you are) you need to add an explicit entry for extra references that will be packed.
Your <Reference> tag is not useful in this context (the PackageReference will already include the assembly reference in your project).

To add assemblies to the packing, you need to add them to a property like this:
<!-- Semicolon separated references list to include in .dna. -->
<!-- Default value: empty -->
<ExcelAddInInclude></ExcelAddInInclude>


You can specify additional .dll libraries to pack by adding an ‘ExcelAddInInclude’ property in your project file, with a ‘;’-separated list of assemblies to pack.

Or you can set it up so that all .dll files in the output directory are packed into the publish\-packed .xlls.

To do this you add an extra target in your project file to build the ‘ExcelAddInInclude’ property automatically

 

  <Target Name="PackedReferences" AfterTargets="AfterBuild" BeforeTargets="ExcelDnaBuild">

    <ItemGroup>

      <References Include="$(OutDir)*.dll" Exclude="$(OutDir)$(TargetFileName)"/>

    </ItemGroup>

    <PropertyGroup>

      <ExcelAddInInclude>@(References)</ExcelAddInInclude>

    </PropertyGroup>

  </Target>


This property is not needed when targeting .NET core (.NET 6+) as we can take the references to pack from the .deps.json file.

-Govert

László Sleisz

unread,
Apr 2, 2025, 5:46:22 AM4/2/25
to Excel-DNA
It works now.
Thank Govert.

László Sleisz

unread,
Apr 2, 2025, 8:45:59 AM4/2/25
to Excel-DNA
One more question.

This is my .csproj file:

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

  <PropertyGroup>
    <TargetFramework>net4.6.2-windows</TargetFramework>
<LangVersion>8.0</LangVersion>
   
    <Nullable>enable</Nullable>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="ExcelDna.Addin" Version="1.8.0" />
    <PackageReference Include="ExcelDna.Integration" Version="1.8.0" />
  </ItemGroup>
  <ItemGroup>
<PackageReference Include="ExcelDna.IntelliSense" Version="1.8.0" />
  </ItemGroup>
  <ItemGroup>
    <Reference Include="ExcelDna.IntelliSense">
      <HintPath>bin\Debug\net4.6.2-windows\ExcelDna.IntelliSense.dll</HintPath>
    </Reference>
    <Reference Include="Metas.UncLib.Core">
      <HintPath>C:\Program Files (x86)\METAS\Metas.UncLib\Metas.UncLib.Core.dll</HintPath>
    </Reference>
    <Reference Include="Metas.UncLib.LinProp">
      <HintPath>C:\Program Files (x86)\METAS\Metas.UncLib\Metas.UncLib.LinProp.dll</HintPath>
    </Reference>
  </ItemGroup>

  <Target Name="PackedReferences" AfterTargets="AfterBuild" BeforeTargets="ExcelDnaBuild">
<ItemGroup>
<References Include="$(OutDir)*.dll" Exclude="$(OutDir)$(TargetFileName)"/>
</ItemGroup>
<PropertyGroup>
<ExcelAddInInclude>@(References)</ExcelAddInInclude>
</PropertyGroup>
</Target>
</Project>

Now are the Metas.UncLib.Core, Metas.UncLib.LinProp  dlls added to the -packed.xll?
I only would like to use and call the Metas libraries from my code, and I do not want to add and pack in my -packed.xll.

Thank you.

László

Govert van Drimmelen

unread,
Apr 2, 2025, 8:56:06 AM4/2/25
to exce...@googlegroups.com

Yes, I think they would be packed – you can see full details of the packing in the build output.

 

If you don’t want some of the .dll files in the output directory to be packed, then you either need to change the ‘PackedReferences’ target specification somehow, or just explicitly list all the libraries that you do want to pack in an <ExcelAddInInclude> list, without having the extra Target etc.

 

 

I also suggest you change the invalid TargetFramework moniker from

    <TargetFramework>net4.6.2-windows</TargetFramework>

to something like

    <TargetFramework>net472</TargetFramework>

 

See Target frameworks in SDK-style projects - .NET | Microsoft Learn

 

Some of the Excel-DNA libraries already require .NET Framework 4.7.2 or later, and that’s the oldest version still supported by Microsoft.

So I’d suggest targeting 4.7.2 instead of 4.6.2. The “-windows” platform suffix is only used for .NET core versions (.NET 6.0+).

 

-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/22b9233c-c496-449e-bef4-fc4c96d61346n%40googlegroups.com.

László Sleisz

unread,
Apr 2, 2025, 10:18:59 AM4/2/25
to Excel-DNA
If I leave only <ExcelAddInInclude>ExcelDna.IntelliSense.dll</ExcelAddInInclude> the UDF functions which calls METAS UncLib does not work from the -packed.xll,
but it works, when I start Excel from Visual Studio.


Unfortunately the METAS UncLib requires .NET Framework V4.6.2.

László

Govert van Drimmelen

unread,
Apr 2, 2025, 11:18:41 AM4/2/25
to exce...@googlegroups.com

If you don’t pack the extra assemblies, you will have to copy them next to the -packed.xll for it to work.

 

Are there errors when you use METAS UncLib under .NET Framework 4.7.2?

On Windows the .NET Framework version gets updated automatically, and has very high compatibility.

You also cannot have .NET Framework 4.6.2 installed alongside a newer .NET Framework 4.x version.

I ask because the next Excel-DNA version will only support .NET Framework 4.7.2+ and I would like to know if there are real issues with this.

László Sleisz

unread,
Apr 3, 2025, 5:47:08 AM4/3/25
to Excel-DNA
I modified the the .NET Framework to 4.7.2,I did not find any error when it use  METAS UncLib.

Now I get error during the build of solution, but thispite of it seem the xll working.
Is it possible to exclude for packing the NationalInstruments*.dlls?

1>MSBUILD : PackExcelAddIn error DNA-818471385: Assembly at bin\Debug\net472\NationalInstruments.UI.Styles3D.dll could not be packed. Possibly a mixed assembly? (These are not supported yet.)
1>MSBUILD : PackExcelAddIn error DNA-818471385: Exception: System.IO.FileLoadException: Could not load file or assembly 'NationalInstruments.UI.Styles3D, Version=19.0.40.49152, Culture=neutral, PublicKeyToken=dc6ad606294fc298' or one of its dependencies. Attempt to load an unverifiable executable with fixups (IAT with more than 2 sections or a TLS section.) (Exception from HRESULT: 0x80131019)
1>MSBUILD : PackExcelAddIn error DNA-818471385: File name: 'NationalInstruments.UI.Styles3D, Version=19.0.40.49152, Culture=neutral, PublicKeyToken=dc6ad606294fc298' ---> System.IO.FileLoadException: Attempt to load an unverifiable executable with fixups (IAT with more than 2 sections or a TLS section.) (Exception from HRESULT: 0x80131019)
1>MSBUILD : PackExcelAddIn error DNA-818471385:    at System.Reflection.RuntimeAssembly.nLoadImage(Byte[] rawAssembly, Byte[] rawSymbolStore, Evidence evidence, StackCrawlMark& stackMark, Boolean fIntrospection, Boolean fSkipIntegrityCheck, SecurityContextSource securityContextSource)
1>MSBUILD : PackExcelAddIn error DNA-818471385:    at System.Reflection.Assembly.Load(Byte[] rawAssembly)
1>MSBUILD : PackExcelAddIn error DNA-818471385:    at ResourceHelper.ResourceUpdater.AddAssembly(String path, String source, Boolean compress, Boolean multithreading, Boolean includePdb)
1>MSBUILD : PackExcelAddIn error DNA-818471385:
1>MSBUILD : PackExcelAddIn error DNA-818471385:
1>PackExcelAddIn:   ~~> Assembly path NationalInstruments.UI.WindowsForms.dll resolved to bin\Debug\net472\NationalInstruments.UI.WindowsForms.dll.
1>PackExcelAddIn:   ->  Updating resource: Type: DNA, Name: __MAIN__, Length: 2301
1>PackExcelAddIn:   ->  Updating resource: Type: ASSEMBLY_LZMA, Name: METAS.VNA.DATA, Length: 204968
1>PackExcelAddIn:   ->  Updating resource: Type: ASSEMBLY_LZMA, Name: NATIONALINSTRUMENTS.UI.WINDOWSFORMS, Length: 98699
1>PackExcelAddIn:   ->  Updating resource: Type: ASSEMBLY_LZMA, Name: NATIONALINSTRUMENTS.COMMON, Length: 219904
1>PackExcelAddIn:   ->  Updating resource: Type: ASSEMBLY_LZMA, Name: MICROSOFT.OFFICE.INTEROP.EXCEL, Length: 229816
1>PackExcelAddIn:   ->  Updating resource: Type: ASSEMBLY_LZMA, Name: NATIONALINSTRUMENTS.UI, Length: 406690
1>PackExcelAddIn:   ->  Updating resource: Type: ASSEMBLY_LZMA, Name: METAS.GUICONTROLS, Length: 461007
1>PackExcelAddIn: Completed Packing bin\Debug\net472\publish\SparameterCorrection-AddIn64-packed.xll.
1>Done building project "SparameterCorrection.csproj".
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
========== Rebuild completed at 11:24 and took 17,597 seconds ==========

László

Govert van Drimmelen

unread,
Apr 3, 2025, 6:39:46 AM4/3/25
to Excel-DNA
Hi  László  ,

Yes, Gemini says it is possible.

-Govert

Okay, yes, it is definitely possible to exclude the NationalInstruments*.dll files from being packed.

You can achieve this by modifying the Exclude attribute within the ItemGroup definition for References. The Exclude attribute can accept multiple patterns, separated by semicolons (;).

Here's how you can modify your Target:

XML
<Target Name="PackedReferences" AfterTargets="AfterBuild" BeforeTargets="ExcelDnaBuild"> <ItemGroup> <References Include="$(OutDir)*.dll" Exclude="$(OutDir)$(TargetFileName);$(OutDir)NationalInstruments*.dll"/> </ItemGroup> <PropertyGroup> <ExcelAddInInclude>@(References)</ExcelAddInInclude> </PropertyGroup> </Target>

Explanation:

  1. Include="$(OutDir)*.dll": This still initially selects all .dll files in your output directory ($(OutDir)).
  2. Exclude="$(OutDir)$(TargetFileName);$(OutDir)NationalInstruments*.dll": This now tells MSBuild to remove items from the included set that match either of these patterns:
    • $(OutDir)$(TargetFileName): Your main project's output DLL (as before).
    • $(OutDir)NationalInstruments*.dll: Any DLL in the output directory whose name starts with "NationalInstruments".

The @(References) item list passed to the ExcelAddInInclude property will now contain all DLLs from the output directory except your main project DLL and any National Instruments DLLs.

László Sleisz

unread,
Apr 3, 2025, 6:54:21 AM4/3/25
to Excel-DNA
Thank you for detailed explanation.
Now it bilds without error.

László
Reply all
Reply to author
Forward
0 new messages