cannot evaluated expression b/c gc is impossible

  • Thread starter Thread starter John A Grandy
  • Start date Start date
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 ?
 
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...
 
Back
Top