How to use the Nuget package in an .Net 6 project with Excel.DNA?

  Kiến thức lập trình

I am working on a .NET6 project and using Excel-DNA (version 1.8.0). I want to integrate some functionality from Intel MKL. Intel provides a NuGet package for redistributing the native libraries, specifically: (version 2024.1.0.692). How can I achieve this integration?

I am trying to build a packed version of my project, and I can observe that the native libraries are included during the packing process. However, this thread mentions that this should not be possible. Despite this, I notice that the MKL native libraries are somehow being included during the build process.

PackExcelAddIn: -> Updating resource: Type: NATIVE_LIBRARY_LZMA, Name: MKL_MC3.2.DLL, Source: Native deps.json, Length: 9615405

Implementing MKL functionality in my code is done using P/Invoke, for example:

 protected double NecessarySamples { get; private set; }
 [DllImport(MKL_DLL_PATH, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, SetLastError = false)]
 private static extern int vslNewStream(out IntPtr stream, int brng, uint seed);

This requires the MKL_DLL_PATH to be set properly on my machine. By placing the .dll files right next to the packed.xll and setting the MKL_DLL_PATH to mkl_rt.2.dll this works fine, but how can I use the already integrated dll in the packed.xll?

If this is not supposed to work at all, how can I prevent Excel-DNA from packing the native MKL DLLs to reduce the package size? The DLLs placed next to the packed version work fine in my case.

Hope someone give me more insights on that topic.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website