Requirements for COM aggregate my custom IRibbonEx

2019-07-18 18:34发布

We have a stripped down Connect class which instantiates the addin's core from an other assembly. Our architectural design is to keep the UI and business logic separated from the loading module (= Connect class), but the restrictions of a shared Addin make us troubles.

what we did in Connect.cs:

[GuidAttribute("XYZ"), ProgId("XYZ")]
public class Connect : Object, IDTExtensibility2, ICustomQueryInterface
{
    ...
    CustomQueryInterfaceResult ICustomQueryInterface.GetInterface(ref Guid iid, 
                                                                  out IntPtr ppv)
    {           
        if (iid.Equals(new Guid("000C0396-0000-0000-C000-000000000046")))
        {
            ppv = Marshal.GetComInterfaceForObject(
                          UIObject,  
                          typeof(IRibbonExtensibility),
                          CustomQueryInterfaceMode.Ignore);
            return CustomQueryInterfaceResult.Handled;
        }

        ppv = IntPtr.Zero;
        return CustomQueryInterfaceResult.NotHandled;            
    }
 }

how the RibbonUI looks like:

public interface IOfficeFluentUI :  IRibbonExtensibility
{
    ...
}

public class OfficeFluentUI : OfficeUIBase, IOfficeFluentUI
{
    ...
    public string GetCustomUI(string RibbonID)
    { 
       ...
    }    
}

The GetInterface function works, it gets the com interface, but unfortunately the GetCustomUI function gets NEVER called. What did we wrong? Thank You very much for any help.

[edit] We already know the "Managed COM Aggregation" and "ICustomQueryInterface" articles. Unfortunately, they did not really help.

0条回答
登录 后发表回答