I've noticed this problem when stepping from code we have source for
to code we don't have source for (a 3rd party dll) when the other code
was compiled width debugging enabled. I most often run into this when
debugging unit tests and I step past the end of one test and control
returns to the test framework.
Does the problem occur always on a particular line of code? What
happens if instead of stepping into this line you step over it? Can
you set a breakpoint later in the program and it works ok (past the
offending line)?
I can step all over the function in file 1 anyway I like but as soon as I
call a function in file 2 the problem starts (I own all source). Willy may
be on to something however since I just discovered that the problem stops
when I pass "null" to the offending function in file 2 instead of the "Form"
reference I normally pass. I think there may be some marshalling issue here
perhaps (with the form's reference). The situation is quite simple however.
A form starts the worker thread going in its "OnLoad()" handler by invoking
"BackgroundWorker.RunWorkerAsync()" (standard 2.0 class). The worker thread
(another function in the form's class) then passes "this" to a function in
another file. That's when all the trouble starts. The debugger goes away for
a 20 second smoke (or whatever it's doing) and then it finally breaks at the
first line in the latter function. At this point however I can't step any
further without the debugger going into la la land permanently. Passing
"null" instead of "this" however eliminates the problem. I thought that
perhaps instead of passing "this", maybe I need to marshal the form's
pointer to the thread somehow but if so then it's news to me (I'm relatively
new to C# and .NET though very experienced in C/C++). Any thoughts?