none
WPF window freezes in Word Addin RRS feed

  • Question

  • Hello,

    I am developing a VSTO 3.5 Addin for Office Word 2007. Recently we have migrated the solution from .Net 3.5 framework to .Net 4.0 framework. After a few problems, the migration was succesfull.

    The problem appeared when we tried to use a Window that was inside a dll. When I try to ShowDialog() that window from Word, the entire application freezes, and I have to close Word from the TaskManager. The (not responsive) on the window does not appear. I created a new Word AddIn that uses .Net 4.0 framework from the start, but the result was the same, freeze of the application.

    But, using the same dlls, we tried the same code in a WPF project. There, everything was oky. The window appeared, and the application did not become inaccesible.

    Does anybody have any idea why this does not work from Word?

    PS: I activated all errors, I remove Managed Code only... No errors appear.

    Best regards,

    Silviu.


    http://www.rosoftlab.net/

    Friday, February 17, 2012 8:50 AM

Answers

  • Hello,

    The results came in. There was a problem with the dlls. The Window was using ActiPro dlls, but the dlls had a problem. After the new dlls came in it seems to have solved the issue.

    Thank you for the help.

    Best regards.,

    Silviu.


    http://www.rosoftlab.net/

    • Marked as answer by Lupu Silviu Wednesday, February 29, 2012 9:32 AM
    Wednesday, February 29, 2012 9:32 AM

All replies

  • use for example process explorer (former sysinternals) when word freezes (or windbg if you're familiar with it) and check stack trace - on which function does it actually hang?
    Friday, February 17, 2012 11:02 AM
  • Hello,

    In debug mode I paused the application and got the stack trace. The method is:

    >    WindowsBase.dll!System.Windows.Threading.Dispatcher.GetMessage(ref System.Windows.Interop.MSG msg, System.IntPtr hwnd, int minMessage, int maxMessage) Line 1682 + 0x30 bytes 

    I was thinking if this could be caused by a CurrentThread.Wait() or Pause inside the Window.

    Best regards,

    Silviu.


    http://www.rosoftlab.net/

    Friday, February 17, 2012 11:11 AM
  • do you have source for that offending code? Paste here code inside Load or Shown event handlers (or their WPF counterparts)
    Friday, February 17, 2012 11:15 AM
  • Hello Damian,

    It would have been easy if I had the code, but unfortunatelly I do not.Here is a more detailed stack trace. The Green arrow shows here my code stopped in my source. The yellow arrow shows where the code is when I Pause the Debugger.

    Could there be an error inside the Window Code that is cached, but that error somehow blocks the Thread of the Window?

    Best regards,

    Silviu.


    http://www.rosoftlab.net/

    Friday, February 17, 2012 11:20 AM
  • Are you invoking this window on the same thread that your add-in was started on? Try to invoke this window on some other thread and tell us about results.

    Friday, February 17, 2012 12:54 PM
  • Hello,

    By running on another thread, the Thread of the Word application is not frozen. I can type in Word.

    But the Window that appears is still frozen.

    Best regards,

    Silviu.


    http://www.rosoftlab.net/

    Friday, February 17, 2012 1:20 PM
  • Can you at least move that window by dragging it with mouse? does it respond at least to paint events? or it does not get redrawn?
    Friday, February 17, 2012 1:36 PM
  • Hello,

    The Window does to respond to anything. If remains where it pops up, it draws the default state (without any data in it), and then does nothing. It should be populated with some data.

    Best regards,

    Silviu.


    http://www.rosoftlab.net/

    Friday, February 17, 2012 2:04 PM
  • Ok, but try to move that window with a mouse, or cover it with some other window and uncover - does it get redrawn or shows 'artifacts' from window that was covering it? It maybe importnant to determine if for example it deadlocks on some synchronization contexts that do pump the paint events or if it simply dealocks on something else.
    Friday, February 17, 2012 2:56 PM
  • Hello,

    Well, the window cannot be moved with the mouse. I moved another explorer window on top of the frozen one, and it remains at it was, with all the controls visible. So a deadlock is happenning, but it does not affect the paint dump. If this is the case, then I have no way of finding where the deadlock happens, as I have no access to the code of the window that freezes.

    Best regards,

    Silviu.


    http://www.rosoftlab.net/

    Monday, February 20, 2012 6:21 AM
  • In this background thread, where you moved logging window, do you set appartment thread to STA? if not, please try to do so (and do not use thread pool thread for this, span your own thread). When exactly in lifecycle of Word do you show your logging window? as a result of some button click? 
    Monday, February 20, 2012 10:01 AM
  • Hello,

    The window is shown from a button in a TaskPane in Word. And when the button is pressed the window appears. I tried with the STA thread, but the result is the same. The thread is blocked and the window behaves the same.

    Best regards,

    Silviu.


    http://www.rosoftlab.net/

    Monday, February 20, 2012 10:17 AM
  • is it possible to get this dll so i can debug it locally?
    Monday, February 20, 2012 10:43 AM
  • Hello,

    Unfortunatelly, I cannot give it to you. I will try contacting the writer of the dll and tell him about the problem and the sympthoms. I will get back with the results.

    Thank you for the help Damian.


    http://www.rosoftlab.net/

    Monday, February 20, 2012 10:44 AM
  • ok, let us know when you have some results. In worst case i will give you some commands to use from inside VS with SOS enabled to see what could be the cause of deadlock.
    Monday, February 20, 2012 2:22 PM
  • Hello Damian,

    Can you give me the commands that I need to run?

    Best regards,

    Silviu.


    http://www.rosoftlab.net/


    • Edited by Lupu Silviu Wednesday, February 22, 2012 9:06 AM
    Wednesday, February 22, 2012 9:04 AM
  • ok, i will try to think of easiest way of determining what could be the cause for deadlock and get back to you as soon as possible.
    Thursday, February 23, 2012 9:34 AM
  • Hello,

    Thank you. In the mean time I will try to contact directly the provider of the dll and describe the problem.

    Best regards,

    Silviu.


    http://www.rosoftlab.net/

    Thursday, February 23, 2012 10:20 AM
  • I'm having the exact same problem. Just curious do you have Office Enterprise 2007 installed? I ran a repair of Office and it fixed the problem.  Haven't determined what file is causing the problem but that's the workaround for us.

    Friday, February 24, 2012 12:16 PM
  • Hello,

    The results came in. There was a problem with the dlls. The Window was using ActiPro dlls, but the dlls had a problem. After the new dlls came in it seems to have solved the issue.

    Thank you for the help.

    Best regards.,

    Silviu.


    http://www.rosoftlab.net/

    • Marked as answer by Lupu Silviu Wednesday, February 29, 2012 9:32 AM
    Wednesday, February 29, 2012 9:32 AM