Open p0n3 opened 3 years ago
That sounds reasonable. Do you mean you need to register the control and CTP add-in in the registry yourself, or at another time?
The ExcelCustomTaskPane code is quite small with two classes and mostly dealing with the on-demand COM registration.
So you could just make a copy of the code from https://github.com/Excel-DNA/ExcelDna/blob/master/Source/ExcelDna.Integration/ExcelCustomTaskPane.cs in your own add-in project, and rename the types to MyCustomTaskPaneFactory' and
MyCustomTaskPaneAddIn. The only coupling I see with the rest of Excel-DNA is the fact that the add-in class derives from
ExcelAddIn`, so you need that. I might be missing something, but it seems worth a try.
Do you mean you need to register the control and CTP add-in in the registry yourself, or at another time?
I just need to have a fixed ProgId to be able to whitelist it in a whole organization. So from my perspective it might be even hardcoded in the library ([ProgId("ExcelDna.CTP")]
or smth like that)
you could just make a copy of the code
I tried, but the problem is there are bunch of internal classes/interfaces inside this file that cannot be accessed from another assembly like: ICustomTaskPaneConsumer
, ProgIdRegistration
, ClsIdRegistration
, SingletonClassFactoryRegistration
which uses another internal method - RegisterClassFactory
and so on and so on.
OK - I see there is some more plumbing behind it, including the class factory provided by Excel-DNA.
any word on this?
Problem There is no easy way to set ProgId/Guid for a Custom Task Pane Helper component (
ExcelCustomTaskPaneAddIn
), which might cause a problem in restricted environments.Details
ExcelCustomTaskPaneAddIn
is an internal class and the instance is being created in theGetCTPFactory
method insideCustomTaskPaneFactory
:LoadComAddIn
checks if the class has ProgId/Guid attribute, and if not it generates id based on the xll path. It works well if you e.g. extendExcelRibbon
class, butExcelCustomTaskPaneAddIn
is an internal class, so you cannot do much with it, therefore it always uses generated id.