2

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.

Community
  • 1
  • 1
  • You don't show the client code, so how can we know that `GetCustomUI` is even called? How do you know that `GetInterface` works? – Zdeslav Vojkovic Apr 10 '13 at 09:53
  • The GetComInterfaceForObject returns a value and does not throw any axceptions, so we assumed it works correctly. The GetCustomUI afaik should be called automatically by Office if the COM aggregation was successful. What do we hav to do with the custom IRibbonExtensibility implementation? Make ComVisible, IUnknownInterface and provide a custom Guid? –  Apr 10 '13 at 09:59
  • 1
    Did it by implementing the IRibbonExtensibility interface in Connect.cs, writing a generic OnAction(CommandID) method and passing all calls further to my UI components.. Dirty, but working. –  Apr 22 '13 at 14:12

0 Answers0