Word 2016 Hanging Intermittently when accessing CurrentTaskPaneInstance

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

Word 2016 Hanging Intermittently when accessing CurrentTaskPaneInstance
Issue unique to Word 2016 
darrendev




Posts: 3
Joined: 2015-10-10
I've got a problem that took me some time to pin down, as it only seems to occur with Word 2016, and it occurs intermittently - sometimes the second time a method is called, other times the 20th time a method is called. The issue occurs when trying to access CurrentTaskPaneInstance for the active document, and it causes Word to hang.

The trigger for this code is a timer that calls a method every 30 seconds. The method then looks like this:


if (this.TaskPanesCollection != null &&
    this.TaskPanesCollection.Collection.Count > 0 &&
    this.TaskPanesCollection.CurrentTaskPaneInstance is MyTaskPane)
    {
       //Do Stuff
    }


It's impossible to debug into the issue, so I've had to rely on writing to a log file at each step to pin it down to the CurrentTaskPaneInstance line. It successfully executes "this.TaskPanesCollection.Collection.Count > 0" but hits the problem on the following line.

Any idea what could be causing this? Everything works ok with Word 2013, the problem only occurs with Word 2016.
Posted 02 Jan, 2016 13:54:37 Top
Dmitry Kostochko


Add-in Express team


Posts: 2731
Joined: 2004-04-05
Hi Darren,

I have just created a small Word add-in and tested it against Word 2016 (16.0.6326.1010) 32-bit. Sorry, but I cannot reproduce the issue. I used the System.Windows.Forms.Timer component (Interval = 1000), please see my code below:


private void adxRibbonButton1_OnClick(object sender, IRibbonControl control, bool pressed)
{
    timer1.Enabled = !timer1.Enabled;
}

private void timer1_Tick(object sender, EventArgs e)
{
    System.Diagnostics.Debug.WriteLine("+++ Tick");
    try
    {
        if (this.adxWordTaskPanesCollectionItem1 != null &&
            this.adxWordTaskPanesCollectionItem1.Collection.Count > 0 &&
            this.adxWordTaskPanesCollectionItem1.CurrentTaskPaneInstance is ADXWordTaskPane1)
        {
            System.Diagnostics.Debug.WriteLine("+++ OK");
            //Do Stuff 
        }
    }
    catch (Exception ex)
    {
        System.Diagnostics.Debug.WriteLine("+++ Exception: " + ex.Message);
    }
}


May it be that I missed something? Shall I perform some additional actions in Word 2016?
Posted 04 Jan, 2016 05:21:24 Top
darrendev




Posts: 3
Joined: 2015-10-10
Hi Dmitry Kostochko,

I encountered the problem on two PCs running Windows 8 and 8.1 while testing. On both PCs I tried both Word 2013 and 2016, thinking at first that it might be a single PC issue, but the problem occurred on both and only for 2016 - 32 and 64 bit versions.

It's one of these intermittent issues that doesn't always appear. To duplicate it, I built and registered a bare bones add in, then opened word documents via double click, as the debugger often prevented the issue. It rarely occurred the first time I opened a document, but the 4th or 5th time it tended to occur repeatedly.

You should double click a word document, leave the document idle for 30 seconds (no mouse or keyboard activity), then return to the document. The forth or fifth document you try this with should trigger the issue, and which point it recurs each time.

I have a sample project I can send you if it helps.
Posted 04 Jan, 2016 14:38:01 Top
Dmitry Kostochko


Add-in Express team


Posts: 2731
Joined: 2004-04-05
Hi Darren,

Thank you for the sample project, it was very helpful.

Unfortunately I cannot reproduce the problem by using your code in my Word 2016 (16.0.6326.1010) 32-bit. I have sent the log file to you by email, please check it.

Also, please let me know what Word 2016 version (including the build number please) you have installed.
Posted 05 Jan, 2016 11:13:10 Top
Tim Webster




Posts: 1
Joined: 2016-01-06
I am also having problems with Word 2016 (16.0.6366.2036) hanging intermittently.
Same code works no problem in all previous versions of Word.
Usually it is when opening a document or template, event log reports cross thread error.
It is a VB.net Winforms application, have tried System.Reflection to use addin to open document and direct from winforms app but hang still happens.
You won't be able to reproduce the issue because the code works OK most of the time then suddenly freezes Word.

Tim Webster
Posted 06 Jan, 2016 21:13:53 Top
Dmitry Kostochko


Add-in Express team


Posts: 2731
Joined: 2004-04-05
Hi Tim,

As far as I understand you have a VB.NET application that interacts with Microsoft Word 2016, correct? If yes, I think you can try contacting Microsoft guys, provide them the information about the error (cross thread error) and code sample, probably they will find out the reason for Word 2016 hanging.
Posted 08 Jan, 2016 04:09:54 Top