Getting current instance of task pane returns null

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

Getting current instance of task pane returns null
 
Sean Devenish




Posts: 55
Joined: 2015-11-30
So we have a custom task pane set up in ADX called 'mainTaskPane'. This normally works fine. We have a major client who, when opening a workbook for the first time, gets some errors due to the fact that the paneInstance referred to in the below code is null.

ADXTaskPane.ADXCustomTaskPaneInstance paneInstance = AddinModule.CurrentInstance.mainTaskPane[AddinModule.CurrentInstance.ExcelApp.ActiveWindow];

Are there any reasons you can think of as to why this line of code would return a 'null' paneInstance?

PaneInstance is defined in the AddinModule as:
public ADXTaskPane mainTaskPane;
Posted 06 Mar, 2017 23:16:17 Top
Andrei Smolin


Add-in Express team


Posts: 14140
Joined: 2006-05-11
Hello Sean,

In what event do you call that code? Please check section Accessing a Form Instance, see the PDF file in the folder {Add-in Express}\Docs on your development PC.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 07 Mar, 2017 02:05:54 Top
Sean Devenish




Posts: 55
Joined: 2015-11-30
Hi and thanks,

the event it is accessed from is ProcessBeforeDoubleClick, I note this isn't included in the 'problem' events in the documentation?
Posted 07 Mar, 2017 03:59:51 Top
Alexander Solomenko


Add-in Express team


Posts: 117
Joined: 2009-02-27
Hello Sean,

Please clarify what this code does:

AddinModule.CurrentInstance.mainTaskPane[AddinModule.CurrentInstance.ExcelApp.ActiveWindow];

The ADXTaskPane class that the mainTaskPane instance points to does not have indexer. Probably it is your own implementation. To be able to pinpoint the problem, we need to review the entire code.
Regards,
Aleksandr Solomenko
Posted 07 Mar, 2017 07:15:02 Top
Sean Devenish




Posts: 55
Joined: 2015-11-30
mainTaskPane is an ADXTaskPane, produced using the AddinModuleDesigner, code generated simply as follows:
public ADXTaskPane mainTaskPane;

We have not modified it at all, we have certainly not extended it! Is there another method that we should be using to access this task pane from an active workbook/window?
Posted 08 Mar, 2017 06:58:48 Top
Alexander Solomenko


Add-in Express team


Posts: 117
Joined: 2009-02-27
Hi Sean,

Sorry, I confused it with Advanced Task Panes. Does it happen when opening a workbook or when the user is already working with it?
Regards,
Aleksandr Solomenko
Posted 09 Mar, 2017 04:45:37 Top
Sean Devenish




Posts: 55
Joined: 2015-11-30
It happens immediately after a workbook is opened, the first time we attempt to use the task pane (so it never displays).

We have found that removing and re-adding our addin while Excel is running will allow the code to run successfully and the task pane will appear.
Posted 09 Mar, 2017 18:02:45 Top
Alexander Solomenko


Add-in Express team


Posts: 117
Joined: 2009-02-27
Hi Sean,

Could you please send me a test project to reproduce this issue? You can use the support email address.
Regards,
Aleksandr Solomenko
Posted 10 Mar, 2017 10:09:32 Top
Sean Devenish




Posts: 55
Joined: 2015-11-30
We can only reproduce the issue on a client server, not in our own environment.
Posted 11 Mar, 2017 05:02:23 Top
Alexander Solomenko


Add-in Express team


Posts: 117
Joined: 2009-02-27
Hi Sean,

We believe that Null received in the ProcessBeforeDoubleClick event is a consequence of another problem that probably occurred at the start of the add-in. Do you have the code that accesses ADXTaskPane on the Excel start, for example, in the WorkbookOpen, NewWorkbook, AddinInitialize, AddinStartupComplete or other events? If yes, then try to run it a bit later, for example, in a 200-300 ms interval by using a timer.
Regards,
Aleksandr Solomenko
Posted 13 Mar, 2017 06:44:54 Top