This project has moved. For the latest updates, please go here.

Error occur when create CustomTaskPane

Nov 11, 2016 at 5:30 AM
I create an excel addin.
[ComVisible(true)]
[COMAddin("Test", "Test Excel插件", 3), RegistryLocation(RegistrySaveLocation.CurrentUser)]
[GuidAttribute("9C1865C9-8E2F-43C4-8594-97599D4E8012"), ProgId("Test.ExcelAddin")]
public class MyAddin : NetOffice.ExcelApi.Tools.COMAddin
{
    public MyAddin()
    {
    }

    public override void CTPFactoryAvailable(object CTPFactoryInst)
    {
        try
        {
            TaskPaneFactory = new ICTPFactory(this.Application, CTPFactoryInst);
            _CustomTaskPane target = this.TaskPaneFactory.CreateCTP(typeof(MyUserControl).FullName, "Test");
            Console.WriteLine(target);
        }
        catch (Exception e)
        {
            MessageBox.Show(e.Message);
        }
    }
}

And MyUserControl.cs is
[ComVisible(true)]
public partial class MyUserControl : UserControl
{
I use NetOffice 1.7.3.0

But when call CreateCTP an exception Unable to create activeX object.


How to add Custom Task Pane ??
Coordinator
Nov 19, 2016 at 8:05 PM
2 questions before,

Your pane has a public constructor without arguments?
Your pane is located in a another assembly as your addin? (or just different namespace)

*Sebastian
Nov 24, 2016 at 4:14 PM
Here my code

namespace Test
{
[ComVisible(true)]
public partial class MyUserControl : UserControl
{
    public MyUserControl()
    {
        InitializeComponent();
    }
}
}





namespace Test
{
[ComVisible(true)]
[COMAddin("Test", "Test Excel插件", 3), RegistryLocation(RegistrySaveLocation.CurrentUser)]
[GuidAttribute("9C1865C9-8E2F-43C4-8594-97599D4E8012"), ProgId("Test.ExcelAddin")]
public class MyAddin : NetOffice.ExcelApi.Tools.COMAddin
{
    public MyAddin()
    {
    }

    public override void CTPFactoryAvailable(object CTPFactoryInst)
    {
        try
        {
            TaskPaneFactory = new ICTPFactory(this.Application, CTPFactoryInst);
            _CustomTaskPane target = this.TaskPaneFactory.CreateCTP(typeof(MyUserControl).FullName, "Test");
            CustomTaskPane pane = (CustomTaskPane) target;
            pane.DockPosition = MsoCTPDockPosition.msoCTPDockPositionRight;
            pane.Visible = true;
            pane.Width = 285;
            pane.DockPosition = MsoCTPDockPosition.msoCTPDockPositionRight;
        }
        catch (Exception e)
        {
            MessageBox.Show(e.Message);
        }
    }
}
}


My csproj add reference ExcelApi NetOffice OfficeApi VBIDEApi


And an exception Unable to create activeX object