0

I'm getting a

ContextSwitchDeadlock

when adding a CustomXMLPart after performing a Documents.Add().

The same code was working fine last week..

I understand that ContextSwitchDeadlock is caused by a long running operation (this is not a duplicate question). Why would the CustomXMLParts.Add() command result in a long running operation?

Anyone come across this? and any ideas how to troubleshoot?

ContextSwitchDeadlock occurred Message: Managed Debugging Assistant 'ContextSwitchDeadlock' has detected a problem in 'C:\Program Files (x86)\Microsoft Office\root\Office16\WINWORD.EXE'. Additional information: The CLR has been unable to transition from COM context 0xfdb520 to COM context 0xfdb468 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.

Matt Fitzmaurice
  • 1,319
  • 4
  • 19
  • 40
  • Possible duplicate of [Visual Studio: ContextSwitchDeadlock](http://stackoverflow.com/questions/578357/visual-studio-contextswitchdeadlock) – meganaut Dec 07 '16 at 02:53
  • Meganaut - question updated to explain that it is not a duplicate – Matt Fitzmaurice Dec 07 '16 at 03:01
  • It would only be a guess without some more information. You should try and show some code surrounding the issue at the very least, otherwise ideally re-create the issue in the most compact piece of code you can and add that to the question. My instinct is that you have loaded a very large or complex file. – meganaut Dec 07 '16 at 03:04
  • 1
    Thanks. Yes, the XML was a lot bigger than I expected. – Matt Fitzmaurice Dec 07 '16 at 03:21

1 Answers1

0

The context switch deadlock can show up when debugging a long running process. For the most part you can ignore it if the process is expected to be long running.

see previous stackoverflow answer

Community
  • 1
  • 1
meganaut
  • 493
  • 2
  • 10