I'm trying to register a ribbon from a dynamically loaded dll.
To try things out, I've defined the simplest possible ribbon class:
[ComVisible(true)]
public class TestDynamicRibbon : ExcelRibbon
{
public override string GetCustomUI(string RibbonID)
{
Trace.Write("It's called!");
return base.GetCustomUI(RibbonID);
}
}
If I define this class inside my ExcelDNA entry point project, the GetCustomUI method is called just fine. It is called indirectly from the ExcelComAddIn.LoadComAddIn() method, through a native method call.
However, in the situation I'm interested in, the TestDynamicRibbon class is not part of the main project. Rather, it is inside a dll that is dynamically loaded at some later point, while Excel is running.
I figured I could just call ExcelComAddIn.LoadComAddIn(testRibbonInstance) but this does not result in GetCustomUI being called. Am I missing some prerequisite step for this?