Excel-DNA / Excel-DNA/ExcelDna
Excel scripting editor and awaitable execution on the main thread
- Dominant language
- C#
- Stars
- 1.5k
- Forks
- 292
- Avg merge
- 20d 12h
- Merged PRs (30d)
- 1
Description
Hi, @govert. You may be interested in my blog post about combining ExcelDna and RoslynPad to get a nice script editor that allows to write UDFs, commands and scripts as easy as Alt+F11 and VBA, but with the power of C# and this library. http://hotforknowledge.com/2016/10/31/5-data_spreads_excel_macros_in_csharp/
However, another reason I am posting this issue is to draw your attention to the XlResult pattern from [here](https://github.com/DataSpreads/ExcelModel/blob/master/src/DataSpreads.ExcelModel/XlResult.cs). It is just a simple awaitable wrapper over some function that will always be executed on the main thread. If I am not mistaken, there is no such short-cut functionality present in the library, and one should rewrite a similar pattern every time. So if you could review it and add such pattern to ExcelDna, it would be great. There are so many subtleties with COM objects, it is easy to make something wrong.
In addition, I believe that I have seen somewhere your comment that if we access COM objects *only and strictly* from the main thread, then we could skip the `Marshal.ReleaseComObject` clean-up of every object and that will be done automatically. Is this really the case? Usage of COM objects in UDFs without cleanup doesn't prevent Excel from exiting, but I am not sure if this is by luck or design?
Finally, is multiple re-registration of UDFs using the `ExcelDna.Registration` project will lead to some leaks and one should keep track of already registered functions and unregister them manually (like [here](http://stackoverflow.com/a/15395954/801189)), or the `ExcelDna.Registration` already does this, or I could just ignore the warnings unless I re-register functions million times?
Many thanks!
Contributor guide
Assessment
This issue has not been assessed yet.