IRibbonExtensibility->从Connect.cs以外的类调用GetCustomUI

时间:2013-04-06 10:42:47

标签: c# outlook-addin ribbon extensibility comaddin

我正在使用Vs2010 - >可扩展性 - >共享加载项

Connect.cs文件

public class Connect : Object, Extensibility.IDTExtensibility2, IRibbonExtensibility 
{
      public string GetCustomUI(string RibbonID) 
      { 
          return MyResources.customUI; 
      }
}

使用上面的代码创建了Ribbons。

我有Class customRibbons.cs

public class Create_Custom_Ribbons : IRibbonExtensibility
{
    Outlook.Application applicationObject;
    public Create_Custom_Ribbons(Outlook.Application application)
    {
        try
        {                               
            applicationObject = application;
            GetCustomUI("");
        }
        catch(Exception ex)
        {
            MessageBox.Show(""+ex.StackTrace);
        }
    }
    public string GetCustomUI(string RibbonID)
    {
        return MyResource.customUI;
    }
}

和Connect.cs

public void OnStartupComplete(ref System.Array custom)
{
        try
        {
            customRibbons.Create_Custom_Ribbons cu = new 
                customRibbons.Create_Custom_Ribbons(applicationObject);
        }
        catch (Exception ex)
        {
            MessageBox.Show("" + ex.StackTrace);
        }
}

但是丝带没有被创造出来。请允许任何人告诉我我做错了什么或者其他任何方式来实现这一点。我无法理解它是不是被创造出来了。

1 个答案:

答案 0 :(得分:2)