Feed on
Posts
Comments

I was talking to John Robbins about debugging .NET applications today during lunch at Devscovery.  He answered a question I had about the infamous ‘CLR has been unable to transition from COM context … for 60 seconds’ error. 

contextswitch

This occurs for me when using a Debugger.Break statement in my Winform code while demonstrating examples during a workshop.  One fix for the problem is to go to the Debug -> Exceptions -> Managed Debug Assistants  menu in Visual Studio and uncheck the ContextSwitchDeadlock

image

I already knew about this Managed Debugging Assistants checkbox and had unchecked it in the past.  The big revelation for me was that this setting is saved in the abc.suo file and is not a global Visual Studio setting.  That means I have to remember to change this for every project I use in my classes!   

24 Responses to “CLR has been unable to transition from COM context for 60 seconds”

  1. tony says:

    What I can find Debug -> Exceptions -> Managed Debug Assistants menu ?

    I use vs.net 2005 professional version, and can’t find Exceptions.

    Thanks

  2. Shai says:

    tony …..

    try Ctrl + Alt + E

  3. An Phu says:

    This just hides the symptom. You are basically ignoring the exception.

    I would like to know what the cause for this deadlock exception.

  4. Walt Ritscher says:

    What the Managed Debugging Assistant (MDA) Context Switch Deadlock is reporting is that an STA COM thread has not responded to a message in 60 seconds.
    If you’ll remember, Single Threaded Apartment COM is done through message passing. This exception does not occur unless that MDA is turned on, which it is by default when running under a debugger.

    Since so many VB6 COM components are only STA and the main thread in Windows Forms is STA, it’s a warning that you’re blocking. If you run into a deadlock outside the debugger, it becomes your ordinary deadlock analysis.

    - from John Robbins

  5. Ramesh says:

    its good, i have lot help for thi site

  6. nfsRagnar says:

    I had the same problem as you. I could solve it with following code:

    Application.DoEvents();

    when you do a loop in a method which takes longer as 60 seconds, the debugger will raise an error..

    while(true)
    {
    //TODO: break; sometime!

    Application.DoEvents();
    }

  7. tapan gupta says:

    This page is very helpful for me.

  8. tapan gupta says:

    i unchecked context switch deadlock and trace line of error then find the solution. thax

  9. Akash varshney says:

    Thanks !! dude … !!

  10. Ronita says:

    This page was very useful for me.Thanks

  11. Nazanin Taha says:

    Thanks a lot,
    It’s very helpful,
    good luck

  12. rutuma says:

    thanks it was very helpful tip

  13. Champ says:

    Thanks its solve my Problem
    Again Thanks Lot

    Afroz

  14. Vanraj says:

    Thanks mate! It solved my problem as well..

  15. Max says:

    great..it works fom me too..thanks!

  16. VMYkyt says:

    Thanks

  17. Sachin says:

    Thanks for g8t post. helped me a lot. thankssssssssssssss

  18. techmio says:

    it works, it don’t show exception up. but the application runs slowly in the point.
    So i think simply uncheck it,not the way.

  19. Sivapriya says:

    John Robbins’s post was really useful and worked well for me.

  20. karthik says:

    thnx…

  21. SATISH says:

    thank you.. it really solved my problem. :)

  22. leandro says:

    Thank you!!!! Good Article