Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / June 2008

Tip: Looking for answers? Try searching our database.

ContextSwitchDeadlock was detected

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sriman - 12 Jun 2007 18:49 GMT
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 - 12 Jun 2007 19:01 GMT
> Hi,
>   I believe this is a framework level issue. I am not sure. Pls help me.
[quoted text clipped - 5 lines]
> ==========
> 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 - 12 Jun 2007 19:15 GMT
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.

> > Hi,
> >   I believe this is a framework level issue. I am not sure. Pls help me.
[quoted text clipped - 24 lines]
>
> Pete
Sriman - 12 Jun 2007 19:15 GMT
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.

> > Hi,
> >   I believe this is a framework level issue. I am not sure. Pls help me.
[quoted text clipped - 24 lines]
>
> Pete
Peter Duniho - 12 Jun 2007 20:02 GMT
> Actually I am working on exporting and importing the data from MySql
> database(thru ODBC) to SqlServer 2005(Sqlclient).  I can not tell exactly
[quoted text clipped - 5 lines]
>   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 - 12 Jun 2007 20:23 GMT
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.

> > Actually I am working on exporting and importing the data from MySql
> > database(thru ODBC) to SqlServer 2005(Sqlclient).  I can not tell exactly
[quoted text clipped - 18 lines]
>
> Pete
Peter Duniho - 13 Jun 2007 01:58 GMT
> 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.

> 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
Sanjay Verma - 20 Jun 2008 12:01 GMT
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.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.