Cannot evaluate expression... optimized?

G

Glenn

OK, I've looked up this message but am not finding how to get rid of
it: "Cannot evaluate expression because a thread is stopped at a point
where garbage collection is impossible, possibly because the code is
optimized"

I'm trying to debug, and it's rather difficult when I can't find the
values of expressions because of whatever is causing this message.

Is there anyone that can tell me what I can do to get rid of it? How
do I un-optimize the code, perhaps?

Any help appreciate, ty :)

Glenn
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Glenn said:
OK, I've looked up this message but am not finding how to get rid of
it: "Cannot evaluate expression because a thread is stopped at a point
where garbage collection is impossible, possibly because the code is
optimized"

I'm trying to debug, and it's rather difficult when I can't find the
values of expressions because of whatever is causing this message.

Is there anyone that can tell me what I can do to get rid of it? How
do I un-optimize the code, perhaps?

Any help appreciate, ty :)

Glenn

When compiling in debug mode, the compiler adds extra nop (no operation)
instructions in the code, so that there is an instruction in the code
for every possible break point. When compiling in release mode, these
extra instructions are not included, and some instructions may be
reorganised so that the final code does not exactly represent the flow
of the source code. If you stop the execution at a point in the code
that can not be matched to a position in the source code, you get this
error.

If you want the final code to exactly match the source code, you have to
compile it in debug mode. You should be aware, though, that some
operations are significantly slower in debug mode. Handling an exception
for example takes something like 100 times longer in debug mode.
 
G

Glenn

When compiling in debug mode, the compiler adds extra nop (no operation)
instructions in the code, so that there is an instruction in the code
for every possible break point. When compiling in release mode, these
extra instructions are not included, and some instructions may be
reorganised so that the final code does not exactly represent the flow
of the source code. If you stop the execution at a point in the code
that can not be matched to a position in the source code, you get this
error.

If you want the final code to exactly match the source code, you have to
compile it in debug mode. You should be aware, though, that some
operations are significantly slower in debug mode. Handling an exception
for example takes something like 100 times longer in debug mode.

Thank you for the reply...

I'm usually just using F5 or F6 to compile/debug.

What should I be doing differently to ensure that I'm compiling in
debug mode?

Thanks again
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Glenn said:
Thank you for the reply...

I'm usually just using F5 or F6 to compile/debug.

What should I be doing differently to ensure that I'm compiling in
debug mode?

Thanks again

In the Build menu you will find Configuration Manager, that you can use
to select and edit the build configurations.

If you customize your toolbar, you can add the Solution Configurations
dropdown. It lets you see what the active setting is, and easily switch
between them.
 
G

Glenn

In the Build menu you will find Configuration Manager, that you can use
to select and edit the build configurations.

If you customize your toolbar, you can add the Solution Configurations
dropdown. It lets you see what the active setting is, and easily switch
between them.

OK, in the express version, it's not under Build... I had to go to
Solution Explorer, then open Properties. I found the check box for
"optimize code", so going to try that.

Thanks,
Glenn
 

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