Error while creating CustomeTaskPane

325 views
Skip to first unread message

Channa Byregowda

unread,
Feb 24, 2017, 12:55:40 PM2/24/17
to exce...@googlegroups.com
All,

We are trying to use wpf user control. expectation is to show/display wpf form in the click event of button in the ribbon.

here is the the method tho show the Custom Task pane.
   public static void ShowCTP()
        {
            if (ctp == null)
            {
                // Make a new one using ExcelDna.Integration.CustomUI.CustomTaskPaneFactory 
                ctp = CustomTaskPaneFactory.CreateCustomTaskPane(typeof(MyUserControl), "My Super Task Pane");
                ctp.Visible = true;
                ctp.DockPosition = MsoCTPDockPosition.msoCTPDockPositionLeft;
                ctp.DockPositionStateChange += ctp_DockPositionStateChange;
                ctp.VisibleStateChange += ctp_VisibleStateChange;
            }
            else
            {
                // Just show it again
                ctp.Visible = true;
            }
        }

I am getting below exception.

System.Runtime.InteropServices.COMException was unhandled by user code
  ErrorCode=-2147467259
  HResult=-2147467259
  Message=Unable to create specified ActiveX control.
  Source=""
  StackTrace:
       at ExcelDna.Integration.CustomUI.ICTPFactory.CreateCTP(String CTPAxID, String CTPTitle, Object CTPParentWindow)
       at ExcelDna.Integration.CustomUI.CustomTaskPaneFactory.CreateCustomTaskPane(String controlProgId, String title, Object parent)
       at ExcelDna.Integration.CustomUI.CustomTaskPaneFactory.CreateCustomTaskPane(Object userControl, String title, Object parent)
       at ExcelDna.Integration.CustomUI.CustomTaskPaneFactory.CreateCustomTaskPane(Type userControlType, String title)
       at Axis.ExcelDNA.CTPManager.ShowCTP() in C:\Risk Management\Utilities\ExcelDNA\Axis.ExcelDNA\Axis.ExcelDNA\Functions\AxisReports.cs:line 114
       at Axis.ExcelDNA.AxisReports.OnShowCTP(IRibbonControl control) in C:\Risk Management\Utilities\ExcelDNA\Axis.ExcelDNA\Axis.ExcelDNA\Functions\AxisReports.cs:line 62
  InnerException: 

Any help in this regard is highly appreciated.

Thanks in advance

--
Channa.

Govert van Drimmelen

unread,
Feb 24, 2017, 1:00:01 PM2/24/17
to exce...@googlegroups.com
1. Does the "MyUserControl" class derive from System.Windows.Forms.UserControl and 
2. is it marked as [ComVisible(true)]?

-Govert


From: exce...@googlegroups.com [exce...@googlegroups.com] on behalf of Channa Byregowda [channa.b...@gmail.com]
Sent: 24 February 2017 07:55 PM
To: exce...@googlegroups.com
Subject: [ExcelDna] Error while creating CustomeTaskPane

--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To post to this group, send email to exce...@googlegroups.com.
Visit this group at https://groups.google.com/group/exceldna.
For more options, visit https://groups.google.com/d/optout.

Channa Byregowda

unread,
Feb 24, 2017, 2:18:06 PM2/24/17
to exce...@googlegroups.com
Got it,  [ComVisible(true)] was missing ... Thank you.

To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+unsubscribe@googlegroups.com.

To post to this group, send email to exce...@googlegroups.com.
Visit this group at https://groups.google.com/group/exceldna.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+unsubscribe@googlegroups.com.

To post to this group, send email to exce...@googlegroups.com.
Visit this group at https://groups.google.com/group/exceldna.
For more options, visit https://groups.google.com/d/optout.



--
Regards,
 C B Gowda
 Ph : +1 312 945 9012
Reply all
Reply to author
Forward
0 new messages