Unable to find the ProgId of the User Control Custom Task Pane

Add-in Express™ Support Service
That's what is more important than anything else

Unable to find the ProgId of the User Control Custom Task Pane
Unable to find the ProgId of the User Control Custom Task Pane 
KristianG




Posts: 39
Joined: 2011-11-03
I have a project in which I have divided the code into several layers (MVVM Architecture). The User Controls are present in the View layer.

When I add a new task pane to the TaskPanes collection of the Addin Module and try to add user control to the task pane via "ControlProgId" property. The designer does not list the ProgId of the User Control.

Any help on this ?
Posted 29 Jun, 2016 02:13:03 Top
Andrei Smolin


Add-in Express team


Posts: 18823
Joined: 2006-05-11
Hello Kristian,

What Visual Studio version are you using?

A workaround is to fill that property in code. The ProgId of a custom task pane is the type name of the UserControl.


Andrei Smolin
Add-in Express Team Leader
Posted 29 Jun, 2016 10:35:53 Top
KristianG




Posts: 39
Joined: 2011-11-03
I am using Visual Studio 2015 Update 3.

I have tried your workaround doing this...


var adxCustomTaskPaneCollection = this.TaskPanes;
if (adxCustomTaskPaneCollection != null && adxCustomTaskPaneCollection.Count > 0)
{
    adxCustomTaskPaneCollection[0].ControlProgID = typeof(TestsUserControl).ToString();
}


and it threw the following exception as soon as I opened the document.

Detailed technical information follows:
---
Date and Time: 6/30/2016 11:51:47 AM
Machine Name: NAVEED-BUTT
IP Address: fe80::b1d5:1f41:7516:c044%11
Current User: SYNERGY\Naveed.butt

Application Domain: D:\OptiMentor\Src\Proofix\Proofix\Proofix.AddIn\bin\Debug\
Assembly Codebase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll
Assembly Full Name: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Assembly Version: 4.0.0.0

Exception Source:
Exception Type: System.Runtime.InteropServices.COMException
Exception Message: Unable to create specified ActiveX control.
Exception Target Site: ForwardCallToInvokeMember

---- Stack Trace ----
System.RuntimeType.ForwardCallToInvokeMember(memberName As String, flags As BindingFlags, target As Object, aWrapperTypes As Int32[], msgData As MessageData&)
mscorlib.dll: N 0191 (0xBF) IL
AddinExpress.MSO.ICTPFactory.CreateCTP(CTPAxID As String, CTPTitle As String, CTPParentWindow As Object)
mscorlib.dll: N 00000 (0x0) JIT
AddinExpress.MSO.ADXAddinModule.AddCustomTaskPanes(parent As Object, outlookFolderName As String)
mscorlib.dll: N 0655 (0x28F) IL
Posted 30 Jun, 2016 02:03:17 Top
Andrei Smolin


Add-in Express team


Posts: 18823
Joined: 2006-05-11
Hello Kristian,

It looks like the constructor of your UserControl fires an exception.


Andrei Smolin
Add-in Express Team Leader
Posted 30 Jun, 2016 02:23:46 Top
KristianG




Posts: 39
Joined: 2011-11-03
I have created a sample application. How can I share that with you, so that you could give me a bit more information on what exactly is the problem here. I can't find an unhandled exception in the code.

I have tried switching on all the exceptions from the exceptions window and it still did not show any exceptions.
Posted 30 Jun, 2016 04:22:20 Top
Andrei Smolin


Add-in Express team


Posts: 18823
Joined: 2006-05-11
Please find the support email address in {Add-in Express installation folder}\readme.txt. And make sure your email contains a link to this topic.


Andrei Smolin
Add-in Express Team Leader
Posted 30 Jun, 2016 04:23:45 Top
Andrei Smolin


Add-in Express team


Posts: 18823
Joined: 2006-05-11
Kristian,

I used the ProgId attribute that you added to the TestUserControl class: I've selected the project's COM Visible check box as well as the Register For Com Interop check box and built the project. This creates registry entries required for the Task Pane to be available for the add-in and host application.

I've commented out the code line you invoke in AddinInitialize; the type name of the TestUserControl isn't equal to the value of the ProgId attribute.

The last step is to specify the value of the ProgId attribute in the constructor of the add-in module

Now register the add-in; this works for me.

Note that you can use another approach. You can create a task pane (UserControl) in the add-in project like you would do with a simple add-in. Then you can use the regular .NET way to put an instance of the TestUserControl control on top of the user control instance that Office creates. This approach doesn't require that the View assembly is COM-visible and TestUserControl is registered for COM interop.


Andrei Smolin
Add-in Express Team Leader
Posted 30 Jun, 2016 10:47:20 Top
KristianG




Posts: 39
Joined: 2011-11-03
I have done that and the User control is registered successfully in the test project, but when I try to do that in my main project. It throws an exception when I open any word document.

Exception Source:
Exception Type: System.Runtime.InteropServices.COMException
Exception Message: Unable to create specified ActiveX control.
Exception Target Site: ForwardCallToInvokeMember

---- Stack Trace ----
System.RuntimeType.ForwardCallToInvokeMember(memberName As String, flags As BindingFlags, target As Object, aWrapperTypes As Int32[], msgData As MessageData&)
mscorlib.dll: N 0191 (0xBF) IL
AddinExpress.MSO.ICTPFactory.CreateCTP(CTPAxID As String, CTPTitle As String, CTPParentWindow As Object)
mscorlib.dll: N 00000 (0x0) JIT
AddinExpress.MSO.ADXAddinModule.AddCustomTaskPanes(parent As Object, outlookFolderName As String)
mscorlib.dll: N 0655 (0x28F) IL
Posted 12 Jul, 2016 07:11:18 Top
Andrei Smolin


Add-in Express team


Posts: 18823
Joined: 2006-05-11
Hello Kristian,

Would the same occur if you comment out the constructor of your UserControl and class-level initializers?


Andrei Smolin
Add-in Express Team Leader
Posted 12 Jul, 2016 07:29:17 Top
KristianG




Posts: 39
Joined: 2011-11-03
Yes. I have commented the constructor of the User Control and then run after building and the exception is still thrown...
Posted 12 Jul, 2016 08:10:51 Top