Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

How to correctly package Google OR-Tools into ExcelDNA to generate a single XLL file

178 views
Skip to first unread message

duze

unread,
Jan 13, 2025, 1:11:00 AMJan 13
to Excel-DNA
I developed an XLL plug-in through ExcelDNA, and it runs normally. I have now introduced Google OR-Tools to implement related calculations for mixed integer programming. The problem now is that after compiling and generating in visual studio 2022, Google.OrTools.dll and google-ortools-native.dll need to be placed in the same directory as -packed.xll for the program to run normally. If you pack the two DLLs into the xll file by writing a packed statement in the DNA file, you can compile successfully, but the XLL program does not run properly, and it prompts that the reference file cannot be found.
Are there any friends who use OR-Tools in DNA? How to correctly pack it into a single xll file?

001.png
002.png
003.png

Development environment:
Visual studio 2022
.NET Framework 4.8
Google OR Tools 9.11.4210

Govert van Drimmelen

unread,
Jan 20, 2025, 5:08:38 AMJan 20
to Excel-DNA
Excel-DNA does not have built-in support for packing native library when running under .NET Framework.
So you need to deal with google-ortools-native.dll yourself.

What you can do is to pack the library into your C# assembly as a resource, then in your AutoOpen you extract from the resource into a local file.
Then call LoadLibrary(...) on the extracted file, so that it is loaded into the process.
Later P/Invoke calls that call the library should then work against the pre-loaded .dll.

-Govert


Reply all
Reply to author
Forward
0 new messages