Search code examples
c#excel-dna

Create custom task pane in c# gets Unable to create specified ActiveX control runtime error


I created a simple custom task pane using excel-dna that contains a combobox and a button in a ".dna" file. But when I move my code to ".cs" file I get an "Unable to create specified ActiveX control" runtime error on this line of code:

ctp = CustomTaskPaneFactory.CreateCustomTaskPane(typeof(MyUserControl), "My Super Task Pane");.

My original code is similar to "https://github.com/KevinT/ExcelDna/blob/master/Distribution/Samples/CustomTaskPane.dna".

Thank you.


Solution

  • I needed to add [ComVisible(true)] on my user control like this:

    [ComVisible(true)]
    public class MyUserControl : UserControl
    {
    }