unable to create specified activex control Office add-in error

Add-ins that directly implement ICustomTaskPaneConsumer expose one or more ActiveX controls that you must register. To use the test add-in for ICustomTaskPaneConsumer, you can either rebuild the add-in, which registers it, or simply register the add-in assembly that contains the managed ActiveX control. You must also be sure to rebuild or re-register the shim, so that the shim registration overrides the add-in registration.
public class TaskPaneX : Office.ICustomTaskPaneConsumer
    private Office.ICTPFactory _taskPaneFactory;
    internal Office.CustomTaskPane _taskPane;
    public void CTPFactoryAvailable(Office.ICTPFactory CTPFactoryInst)
            _taskPaneFactory = CTPFactoryInst;
            _taskPane = _taskPaneFactory.CreateCTP(
"ContosoAddin.SimpleControl", "SimpleControl", Type.Missing);
        catch (Exception ex)
1. Make sure user control class has Comvisible and ProgID defined. See for above code:
public partial class SimpleControl : UserControl
    public SimpleControl()

2. Make sure the managed assembly must be strong name assembly and would be better if shim assembly has same GUID /ProgID.
3. First register the original shared add-in assembly:

cd C:\Windows\Microsoft.NET\Framework\v2.0.50727
regasm /codebase "<install_locationC:\Data\COMShims\2.3\Sample Managed Assemblies\TestExcel2007Addin\TestExcel2007Addin\bin\Debug\TestExcel2007Addin.dll"

4. Register shim assembly:

Regsvr32 “<shim assembly path>”

5. Test the add-in.

Hope, It helps.

No comments:

Post a Comment