Home All Groups Group Topic Archive Search About

Can't evaluate expressionin IDE debug mode

Author
27 Apr 2010 7:16 PM
Saga
So I am stepping through my program and I either hover
or select an expression and hit F9 and its value is displayed,
but then in some cases I get this message:

"Cannot evaluate expression because we are stopped in a
place where garbage collection is impossible, possibly because
the code of the current method may be optimized."

I searched for it and got various hits, some of them useful,
but not enough to solve my problem. I have never encountered
this message before. The only difference for this specific routine
is that I copied and pasted it from a VB6 project. Initially it had
lots of errors (102 to be exact), but I changed the code accordingly
and got it down to 0 errors.

For example, I get the message on this line:

begin.dteBegDate = DateSerial(CInt(strAr(2).Substring(strAr(2).Length() - 2,
2)), _
                   CInt(strAr(2).Substring(0, 2)),
CInt(strAr(2).Substring(2, 2)))

Where strAr(2) is "042710". If I highlight any of the following line and hit
F9 I get
the message:

strAr(2).Substring(strAr(2).Length() - 2, 2)
or
cint(strAr(2).Substring(strAr(2).Length() - 2, 2))
or
BData.dteBegDate

But if I highlight the following line I get the value correctly:

BData.strVehicleId = strAr(4).Trim()

BData is a structure. I already checked the JIT suppress option as
recommended
by the information that I found, but this does not seem to be the issue. I
suspect
that some of my .NET code may not be up to spec. Any suggestions are
welcomed.
Thank you, Saga

Author
27 Apr 2010 8:12 PM
Tom Shelton
On 2010-04-27, Saga <antiSpam@nowhere.com> wrote:
> So I am stepping through my program and I either hover
> or select an expression and hit F9 and its value is displayed,
> but then in some cases I get this message:
>
> "Cannot evaluate expression because we are stopped in a
> place where garbage collection is impossible, possibly because
> the code of the current method may be optimized."
>

Are you stepping through in debug mode?  There are various things that will
not work properly if you are steping through in Release mode...

--
Tom Shelton
Author
27 Apr 2010 8:38 PM
Saga
Thank you for the reply. I could not find where to verify the
mode that my project was in. Ifianlly found that the "Show
advanced build configurations" checkbox needed to be
checked :-) Anyways, I checked and the rpojcect is in
Debug mode. Regards, Saga


Show quoteHide quote
"Tom Shelton" <tom_shel***@comcastXXXXXXX.net> wrote in message
news:Oj%23irXk5KHA.1888@TK2MSFTNGP05.phx.gbl...
> On 2010-04-27, Saga <antiSpam@nowhere.com> wrote:
>> So I am stepping through my program and I either hover
>> or select an expression and hit F9 and its value is displayed,
>> but then in some cases I get this message:
>>
>> "Cannot evaluate expression because we are stopped in a
>> place where garbage collection is impossible, possibly because
>> the code of the current method may be optimized."
>>
>
> Are you stepping through in debug mode?  There are various things that
> will
> not work properly if you are steping through in Release mode...
>
> --
> Tom Shelton
Author
28 Apr 2010 6:32 PM
Saga
Any chance that using Dateserial() function could be causing
this? Is there a better way to assign a date value to a date
variable when I have the year, month and day in separate
integer variables? Saga


Show quoteHide quote
"Saga" <antiSpam@nowhere.com> wrote in message
news:%23Xz9t4j5KHA.3804@TK2MSFTNGP05.phx.gbl...
> So I am stepping through my program and I either hover
> or select an expression and hit F9 and its value is displayed,
> but then in some cases I get this message:
>
> "Cannot evaluate expression because we are stopped in a
> place where garbage collection is impossible, possibly because
> the code of the current method may be optimized."
>
> I searched for it and got various hits, some of them useful,
> but not enough to solve my problem. I have never encountered
> this message before. The only difference for this specific routine
> is that I copied and pasted it from a VB6 project. Initially it had
> lots of errors (102 to be exact), but I changed the code accordingly
> and got it down to 0 errors.
>
> For example, I get the message on this line:
>
> begin.dteBegDate = DateSerial(CInt(strAr(2).Substring(strAr(2).Length() -
> 2, 2)), _
>                   CInt(strAr(2).Substring(0, 2)),
> CInt(strAr(2).Substring(2, 2)))
>
> Where strAr(2) is "042710". If I highlight any of the following line and
> hit F9 I get
> the message:
>
> strAr(2).Substring(strAr(2).Length() - 2, 2)
> or
> cint(strAr(2).Substring(strAr(2).Length() - 2, 2))
> or
> BData.dteBegDate
>
> But if I highlight the following line I get the value correctly:
>
> BData.strVehicleId = strAr(4).Trim()
>
> BData is a structure. I already checked the JIT suppress option as
> recommended
> by the information that I found, but this does not seem to be the issue. I
> suspect
> that some of my .NET code may not be up to spec. Any suggestions are
> welcomed.
> Thank you, Saga
>
>
>
Author
28 Apr 2010 7:06 PM
Armin Zingler
Am 28.04.2010 20:32, schrieb Saga:
> Any chance that using Dateserial() function could be causing
> this?

Can't answer this one but...

> Is there a better way to assign a date value to a date
> variable when I have the year, month and day in separate
> integer variables?

   d = New Date(year, month, day)

--
Armin
Author
28 Apr 2010 8:19 PM
Saga
Thanks! I'll make that change. Saga

Show quoteHide quote
"Armin Zingler" <az.nospam@freenet.de> wrote in message
news:%23Sz%23fYw5KHA.5016@TK2MSFTNGP02.phx.gbl...
> Am 28.04.2010 20:32, schrieb Saga:
>> Any chance that using Dateserial() function could be causing
>> this?
>
> Can't answer this one but...
>
>> Is there a better way to assign a date value to a date
>> variable when I have the year, month and day in separate
>> integer variables?
>
>   d = New Date(year, month, day)
>
> --
> Armin