Discussion:
ContextSwitchDeadlock was detected
(too old to reply)
Sriman
2007-06-12 17:49:00 UTC
Permalink
Hi,
I believe this is a framework level issue. I am not sure. Pls help me.
Developement Evn:
================
Vb.net 2005( framework 2.0)

Error:
==========
ContextSwitchDeadlock was detected
Message: The CLR has been unable to transition from COM context 0x1b2938 to
COM context 0x1b2aa8 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.

Regards,
Sri
Peter Duniho
2007-06-12 18:01:34 UTC
Permalink
On Tue, 12 Jun 2007 10:49:00 -0700, Sriman =
Hi,
I believe this is a framework level issue. I am not sure. Pls help m=
e.
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Vb.net 2005( framework 2.0)
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
ContextSwitchDeadlock was detected
When did you get the error?

I see that on a semi-regular basis if I am debugging particular kinds of=
=

code and have been spending any significant amount of time (for example,=
=

more than 60 seconds :) ) with the process stopped.

As near as I can tell it's a false-positive error message.

If you are seeing it in a different type of situation, particularly if y=
ou =

have no good explanation for why a particular thread would remain stoppe=
d =

for a minute or more, then you should look into it. Otherwise, there's =
=

probably nothing to worry about.

(In fact, I simply disabled the error message, because if I really do ha=
ve =

a deadlock situation in my code somewhere, I will notice it for reasons =
=

other than geting the MDA message).

Pete
Sriman
2007-06-12 18:15:02 UTC
Permalink
Actually I am working on exporting and importing the data from MySql
database(thru ODBC) to SqlServer 2005(Sqlclient). I can not tell exactly
where i am getting this error. I got this error in release mode also. even i
am unable to catch that exception also. I didn't see the errors, when i ran
the exe directly.
How did you disable the errors? did you mean try..catch? Please clarify..


Regards,
Sri.
Post by Peter Duniho
On Tue, 12 Jun 2007 10:49:00 -0700, Sriman
Post by Sriman
Hi,
I believe this is a framework level issue. I am not sure. Pls help me.
================
Vb.net 2005( framework 2.0)
==========
ContextSwitchDeadlock was detected
When did you get the error?
I see that on a semi-regular basis if I am debugging particular kinds of
code and have been spending any significant amount of time (for example,
more than 60 seconds :) ) with the process stopped.
As near as I can tell it's a false-positive error message.
If you are seeing it in a different type of situation, particularly if you
have no good explanation for why a particular thread would remain stopped
for a minute or more, then you should look into it. Otherwise, there's
probably nothing to worry about.
(In fact, I simply disabled the error message, because if I really do have
a deadlock situation in my code somewhere, I will notice it for reasons
other than geting the MDA message).
Pete
Sriman
2007-06-12 18:15:02 UTC
Permalink
Actually I am working on exporting and importing the data from MySql
database(thru ODBC) to SqlServer 2005(Sqlclient). I can not tell exactly
where i am getting this error. I got this error in release mode also. even i
am unable to catch that exception also. I didn't see the errors, when i ran
the exe directly.
How did you disable the errors? do you mean try..catch? Please clarify..


Regards,
Sri.
Post by Peter Duniho
On Tue, 12 Jun 2007 10:49:00 -0700, Sriman
Post by Sriman
Hi,
I believe this is a framework level issue. I am not sure. Pls help me.
================
Vb.net 2005( framework 2.0)
==========
ContextSwitchDeadlock was detected
When did you get the error?
I see that on a semi-regular basis if I am debugging particular kinds of
code and have been spending any significant amount of time (for example,
more than 60 seconds :) ) with the process stopped.
As near as I can tell it's a false-positive error message.
If you are seeing it in a different type of situation, particularly if you
have no good explanation for why a particular thread would remain stopped
for a minute or more, then you should look into it. Otherwise, there's
probably nothing to worry about.
(In fact, I simply disabled the error message, because if I really do have
a deadlock situation in my code somewhere, I will notice it for reasons
other than geting the MDA message).
Pete
Peter Duniho
2007-06-12 19:02:33 UTC
Permalink
On Tue, 12 Jun 2007 11:15:02 -0700, Sriman
Post by Sriman
Actually I am working on exporting and importing the data from MySql
database(thru ODBC) to SqlServer 2005(Sqlclient). I can not tell exactly
where i am getting this error. I got this error in release mode also. even i
am unable to catch that exception also. I didn't see the errors, when i ran
the exe directly.
How did you disable the errors? do you mean try..catch? Please clarify..
The "ContextSwitchDeadlock" error is, as far as I know, _only_ available
as a "Managed Debugging Assistant". You can disable it by looking under
that section in the "Debug/Exception..." dialog box. However, you should
only ever see it when you are actually debugging. If you run your
application without the debugger, it shouldn't happen.

Are you seeing this MDA appear at times when you are not using the
debugger? If so, I'm afraid I don't have any idea of what's going on. I
didn't even realize that the MDA exceptions could happen when not using
the debugger.

Pete
Sriman
2007-06-12 19:23:07 UTC
Permalink
Hi peter,

Thanks for the response. Yes, I can see the eror with out debugger
also(run the application using IDE in Release mode(No debug marks)). No
errors If i run the exe direct from the release folder.

Regards,
Sriman.
Post by Peter Duniho
On Tue, 12 Jun 2007 11:15:02 -0700, Sriman
Post by Sriman
Actually I am working on exporting and importing the data from MySql
database(thru ODBC) to SqlServer 2005(Sqlclient). I can not tell exactly
where i am getting this error. I got this error in release mode also. even i
am unable to catch that exception also. I didn't see the errors, when i ran
the exe directly.
How did you disable the errors? do you mean try..catch? Please clarify..
The "ContextSwitchDeadlock" error is, as far as I know, _only_ available
as a "Managed Debugging Assistant". You can disable it by looking under
that section in the "Debug/Exception..." dialog box. However, you should
only ever see it when you are actually debugging. If you run your
application without the debugger, it shouldn't happen.
Are you seeing this MDA appear at times when you are not using the
debugger? If so, I'm afraid I don't have any idea of what's going on. I
didn't even realize that the MDA exceptions could happen when not using
the debugger.
Pete
Peter Duniho
2007-06-13 00:58:37 UTC
Permalink
On Tue, 12 Jun 2007 12:23:07 -0700, Sriman
Post by Sriman
Hi peter,
Thanks for the response. Yes, I can see the eror with out debugger
also(run the application using IDE in Release mode(No debug marks)).
It's not clear that you understand my question.

If you run your program by using the Visual Studio IDE, then you are
running with the debugger. The debugger is attached, whether you realize
it or not.
Post by Sriman
No errors If i run the exe direct from the release folder.
In other words, without the debugger the error doesn't happen.

Now, all that said, if you are not actually interrupting your program with
the debugger or otherwise doing something that would be expected and
normally cause a thread to remain active in preference for another thread
in your application, then perhaps the error is telling you something
useful.

Note that an "expected and normal" situation might be, for example, making
a database query that takes a very long time. I don't know what sort of
query this might be, but maybe something that tries to extract all of the
data from a very large data, for example.

Only you can really decide for sure whether the error is of concern or
not, since only you can judge whether it's reasonable for your application
to remain stuck in one thread for a long time. If it's not okay, then you
should probably look closer at which threads the debugger is talking about
and why you can't switch from one to the other within the MDA's time limit.

Pete
unknown
2008-06-20 11:01:33 UTC
Permalink
See the following article to find the solution ::

http://harriyott.com/2006/05/contextswitchdeadlock-was-detected.aspx

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=271410&SiteID=1

Hope it helps.
kumari sony
2011-09-27 07:00:42 UTC
Permalink
Simply select Exceptions from the Debug menu in the visual studio 2005 window , the Edxception Dialog box wil popup , select the Managed Debugging Assistants Exception Node , then select ContextSwitchDeadlock and remove the select from Thrown column . this will stop the vs from throwing the ContextSwitchDeadlock exception.


Hope it helps...
Post by Sriman
Hi,
I believe this is a framework level issue. I am not sure. Pls help me.
================
Vb.net 2005( framework 2.0)
==========
ContextSwitchDeadlock was detected
Message: The CLR has been unable to transition from COM context 0x1b2938 to
COM context 0x1b2aa8 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.
Regards,
Sri
Post by Peter Duniho
On Tue, 12 Jun 2007 10:49:00 -0700, Sriman =
e.
When did you get the error?
I see that on a semi-regular basis if I am debugging particular kinds of=
=
code and have been spending any significant amount of time (for example,=
=
more than 60 seconds :) ) with the process stopped.
As near as I can tell it's a false-positive error message.
If you are seeing it in a different type of situation, particularly if y=
ou =
have no good explanation for why a particular thread would remain stoppe=
d =
for a minute or more, then you should look into it. Otherwise, there's =
=
probably nothing to worry about.
(In fact, I simply disabled the error message, because if I really do ha=
ve =
a deadlock situation in my code somewhere, I will notice it for reasons =
=
other than geting the MDA message).
Pete
Post by Sriman
Actually I am working on exporting and importing the data from MySql
database(thru ODBC) to SqlServer 2005(Sqlclient). I can not tell exactly
where i am getting this error. I got this error in release mode also. even i
am unable to catch that exception also. I didn't see the errors, when i ran
the exe directly.
How did you disable the errors? do you mean try..catch? Please clarify..
Regards,
Sri.
Post by Sriman
Actually I am working on exporting and importing the data from MySql
database(thru ODBC) to SqlServer 2005(Sqlclient). I can not tell exactly
where i am getting this error. I got this error in release mode also. even i
am unable to catch that exception also. I didn't see the errors, when i ran
the exe directly.
How did you disable the errors? did you mean try..catch? Please clarify..
Regards,
Sri.
Post by Peter Duniho
On Tue, 12 Jun 2007 11:15:02 -0700, Sriman
The "ContextSwitchDeadlock" error is, as far as I know, _only_ available
as a "Managed Debugging Assistant". You can disable it by looking under
that section in the "Debug/Exception..." dialog box. However, you should
only ever see it when you are actually debugging. If you run your
application without the debugger, it shouldn't happen.
Are you seeing this MDA appear at times when you are not using the
debugger? If so, I'm afraid I don't have any idea of what's going on. I
didn't even realize that the MDA exceptions could happen when not using
the debugger.
Pete
Post by Sriman
Hi peter,
Thanks for the response. Yes, I can see the eror with out debugger
also(run the application using IDE in Release mode(No debug marks)). No
errors If i run the exe direct from the release folder.
Regards,
Sriman.
Post by Peter Duniho
On Tue, 12 Jun 2007 12:23:07 -0700, Sriman
It's not clear that you understand my question.
If you run your program by using the Visual Studio IDE, then you are
running with the debugger. The debugger is attached, whether you realize
it or not.
In other words, without the debugger the error doesn't happen.
Now, all that said, if you are not actually interrupting your program with
the debugger or otherwise doing something that would be expected and
normally cause a thread to remain active in preference for another thread
in your application, then perhaps the error is telling you something
useful.
Note that an "expected and normal" situation might be, for example, making
a database query that takes a very long time. I don't know what sort of
query this might be, but maybe something that tries to extract all of the
data from a very large data, for example.
Only you can really decide for sure whether the error is of concern or
not, since only you can judge whether it's reasonable for your application
to remain stuck in one thread for a long time. If it's not okay, then you
should probably look closer at which threads the debugger is talking about
and why you can't switch from one to the other within the MDA's time limit.
Pete
Post by unknown
http://harriyott.com/2006/05/contextswitchdeadlock-was-detected.aspx
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=271410&SiteID=1
Hope it helps.
Loading...