Excel-DNA / ExcelDna

Excel-DNA - Free and easy .NET for Excel. This repository contains the core Excel-DNA library.
https://excel-dna.net
zlib License
1.26k stars 270 forks source link

Embedded Resource #649

Closed anat0x closed 7 months ago

anat0x commented 8 months ago

hello, for example, when I put a file on the desktop and open it, it tells me that it could not find the .dna file, I tried embedded resource from Visual Basic, but to no avail. how can I make the necessary files (.dna .dll) accompany the .xll file? e

govert commented 8 months ago

Building your project should also result in two '-packed' add-in (32-bit and 64-bit). These have the .dna file and potentially other dependencies inside. They should be under a 'publish' subdirectory under your build output if you're using an SDK-style project file, else directly in the output directory.

anat0x commented 7 months ago

თქვენი პროექტის აშენებამ ასევე უნდა გამოიწვიოს ორი „შეფუთული“ დანამატი (32-ბიტიანი და 64-ბიტიანი). მათ აქვთ .dna ფაილი და პოტენციურად სხვა დამოკიდებულებები შიგნით. ისინი უნდა იყოს "გამოქვეყნების" ქვედირექტორის ქვეშ თქვენი build გამომავალი გამომავალი ვერსიის ქვეშ, თუ იყენებთ SDK სტილის პროექტის ფაილს, სხვა შემთხვევაში პირდაპირ გამომავალი დირექტორიაში.

It's clear, but how is it possible to have .dll and .dna files inside and only need to open the .xll file?for example, how can I give my friend only the .xll file so that it works without problems, without the .dna and .dll files in the same directory

govert commented 7 months ago

how is it possible to have .dll and .dna files inside

That's what the -packed files are about. They have these inside.

how can I give my friend only the .xll file so that it works without problems, without the .dna and .dll files in the same directory

You make sure the packed .xll contains your dependencies, and then give your friend only the -packed file.

The packed add-in always has the .dna file inside. For other dependencies, the story is like this:

• If you’re targeting .NET Framework 4.x, you need to add files to be packed into the .csproj file like this:

    <ExcelAddInInclude>ExcelDna.IntelliSense.dll;MyCalculationLib.dll</ExcelAddInInclude>

• This can be a semi-colon separated list with other files. • You can generate the list from all the .dll files in the output directory like this:

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

    <PropertyGroup>
      <ExcelAddInInclude>@(References)</ExcelAddInInclude>
    </PropertyGroup>
  </Target>

• If you’re targeting .NET 6, then the packing list will be generated automatically from the .deps.json file.

anat0x commented 7 months ago

how is it possible to have .dll and .dna files inside

That's what the -packed files are about. They have these inside.

how can I give my friend only the .xll file so that it works without problems, without the .dna and .dll files in the same directory

You make sure the packed .xll contains your dependencies, and then give your friend only the -packed file.

The packed add-in always has the .dna file inside. For other dependencies, the story is like this:

• If you’re targeting .NET Framework 4.x, you need to add files to be packed into the .csproj file like this:

    <ExcelAddInInclude>ExcelDna.IntelliSense.dll;MyCalculationLib.dll</ExcelAddInInclude>

• This can be a semi-colon separated list with other files. • You can generate the list from all the .dll files in the output directory like this:

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

    <PropertyGroup>
      <ExcelAddInInclude>@(References)</ExcelAddInInclude>
    </PropertyGroup>
  </Target>

• If you’re targeting .NET 6, then the packing list will be generated automatically from the .deps.json file.

I solved that problem, why is it written to me on another computer?

Screenshot 2023-11-02 182213

govert commented 7 months ago

If you are targeting .NET 6, then the .NET 6 Desktop runtime must be installed on the client.

Using Excel-DNA 1.7.0-rc9 should give you a better error message than that.

What version of Excel-DNA are you using?

anat0x commented 7 months ago

If you are targeting .NET 6, then the .NET 6 Desktop runtime must be installed on the client.

Using Excel-DNA 1.7.0-rc9 should give you a better error message than that.

What version of Excel-DNA are you using?

1.7.0-rc9 gives me this error: 1 7 The previous version was 1.6 but when I compile it gives me this error so I got ExcelDna64.xll file from net6.0-windows7.0 this folder maybe it solves the problem net.4.5.2 ExcelDna64.xll file but I can't get it 1 6

govert commented 7 months ago

The problem is that your build is still using the v1.6.0 build task, even though you are trying to build for 1.7.0-rc9.

image

Sometimes this happens because Visual Studio does not recycle the build process properly - you can close Visual Studio and have some tea (it takes a while for the VBCSCompiler.exe process to stop), then try again.

Also, when moving to an SDK-style project file, I've found that one should delete the "packages.config" file and the "packages" folder under the project directory. These continue to make interfere, and the NuGet packages are now cached in a different place.