cannot evaluated expression b/c gc is impossible

J

John A Grandy

I am trying to track down a mysterious null reference exception that occurs
on making a call to a method in a assembly referenced by my project ( i.e.
flow-of-control never arrives at the code inside the called method )

try
{
// call to method in referenced assembly ( c# )
}
catch ( Exception ex )
{
throw ex;
}

However, I can not evaluate ex ... the reason given is :

{Cannot evaluate expression because a thread is stopped at a point where
garbage collection is impossible, possibly because the code is optimized.}

How can I debug this ?
 
P

puzzlecracker

I am trying to track down a mysterious null reference exception that occurs
on making a call to a method in a assembly referenced by my project ( i.e.
flow-of-control never arrives at the code inside the called method )

try
{
// call to method in referenced assembly ( c# )}

catch ( Exception ex )
{
throw ex;

}

However, I can not evaluate ex ... the reason given is :

{Cannot evaluate expression because a thread is stopped at a point where
garbage collection is impossible, possibly because the code is optimized.}

How can I debug this ?

You can try rebuilding the code in debug mode. Also, try print the
state of the method in the "finally" clause (or use a debug, setting a
break prior to the error occurrence):

try
{
// call to method in referenced assembly ( c# )}

catch ( Exception ex )
{
throw ex;
}finally
{

//This will execute before anything on the stack of this method
will be GC'd
}


It's actually interesting about the GC's behavior in the presence of
exception and the time local stack is clean-up...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top