Requirements for COM aggregate my custom IRibbonExtensibility implementation?

瘦欲@ 提交于 2019-12-24 03:25:47

问题


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.

来源:https://stackoverflow.com/questions/15921925/requirements-for-com-aggregate-my-custom-iribbonextensibility-implementation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!