Hello,
I would like to share my recent experience migrating an Excel-DNA project from classic JIT compilation to Native AOT.
While it wasn't entirely straightforward due to the inherent nature of AOT, I managed to build a working add-in. Hoping this feedback can be helpful to someone, I'd like to highlight some difficulties I've encountered (mostly regarding the Ribbon) and share an simplified example repository.
difficulties encountered:
Conflict with ExcelDna.IntelliSense: To properly access core interfaces and classes such as IExcelRibbon, RibbonControl, and IDynamic, I noticed that the ExcelDna.IntelliSense package must not be included in the project. It took me quite a while to figure this out; I would recommend highlighting this more clearly in the documentation.
Ribbon Event Limitations (onLoad, getVisible, getLabel): Under AOT, these and similar events do not seem to function correctly. Specifically for onLoad, the received argument is cast to ExcelDna.Integration.CustomUI.RibbonControl, but the instance ends up empty. This prevents retrieving the proper interface needed to call .Invalidate() on the Ribbon—a feature I rely on for dynamic UI updates.
loadImage='LoadImage' Attribute: To load icons using the official examples, you must explicitly add loadImage='LoadImage' inside the <customUI> element. I assume LoadImage is an internal callback method within Excel-DNA that isn't publicly exposed. Much like the IntelliSense issue, adding a note about this in the documentation would be very helpful.
32-bit AOT Publishing Anomaly (win-x86): Since I run a 64-bit version of Excel, I haven't been able to physically test the 32-bit add-in, but I believe there might be an issue in the publishing workflow. Although the project DLL compiles correctly for x86, Excel-DNA targets copy the 64-bit loader into the publish folder (deduced both from the ExcelDNAtest-AddIn64.xll file name and by inspecting the header via dumpbin /headers). It might be an error on my end, but I haven't been able to fully trace the underlying workflow.
I have set up a public repository containing a working setup that addresses these scenarios: https://github.com/luigicondimax/ExcelDNAtest
I implemented and tested several solutions in this project that might be useful to others:
Parallel Development Path: Handling both classic JIT mode and Native AOT within the same project file, with both configured for 32-bit and 64-bit publishing.
Inno Setup Installer: I've seen several deployment-related requests on the forum in the past, so I included a complete Inno Setup script that automatically handles add-in installation for different scenarios (requires Inno Setup installed to compile).
Avalonia UI: Instead of traditional Windows Forms or WPF, I integrated Avalonia UI (which is fully AOT-compliant) to handle dialog windows, custom forms, and message boxes.
Localization: I have adapted to the AOT compilation a Ribbon and function translation system that uses dynamic registration and the interface invalidation mechanism.
I translated and adapted this text with gemini so there might be some errors.
Can you confirm me the problem with the ribbon and the 32 bit compilation?
Thanks
Hi Luigi,
Thank you very much for writing this up and the detailed feedback.
I’ll go through and see how we can best address the issues you raise.
Regards,
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/9d5f0237-cb1f-4127-a61f-8b5b8615416cn%40googlegroups.com.