473,405 Members | 2,344 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Cannot evaluate expression because the code of the current method is optimized.

Hi,

I'm doing a algorithm to calcule Earliest Start et Latest Start for a
Graph with Nodes and Arcs. (like a PERT diagram) . Unfortunatly, i
receive a wierd exception message for a specific generic (LIST<T>)

This method is calculed often before is put in a foreach statement. At
the first iterration, all is ok. But at the seond, I receive "Cannot
evaluate expression because the code of the current method is
optimized."

His someone can help me ? Here's my code.

Steeve

public void SetEarliestStart()
{
foreach (Node n in _NodeList)
{
n.Visited = false;
n.EarliestStart = 0;
n.Max = 0;
}

//Start Node
_NodeList[0].Visited = true;
_NodeList[0].EarliestStart = 0;

bool AllPrecVisited;
while(_NodeList[_NodeList.Count-1].Visited != true)
{
List<NodeNoneVisitedNodes = new List<Node>();
NoneVisitedNodes = _NodeList.FindAll(delegate(Node
node) //Exception is throw here !!

{

return node.Visited == false;

});
foreach(Node n in NoneVisitedNodes)
{
AllPrecVisited =
n.NodePrecList.TrueForAll(delegate(Node node)

{

return node.Visited == true;

});
if (AllPrecVisited)
{
foreach (Arc a in n.ArcPrecList)
{
if (n.Max < a.NodeStart.EarliestStart +
a.MoveTime
+
a.WorkTime)
{
n.Max = a.NodeStart.EarliestStart +
a.MoveTime + a.WorkTime;
}
}
n.EarliestStart = n.Max;
n.Visited = true;
break;

}
}
}
}

Sep 4 '06 #1
2 15755
Your Code is set to Optimize. In this mode, the compiler does code
optimizations any can sometimes not be able to debug.

Solution is to disable Optimizations while debugging.
1) Open the project properites from the Solution Explorer by right
clicking and selecting Properties
2) The Project Properties Dialog is shown.
3) Select your configuration from the Configuration Drop Down Box.
4) Under Configuration Properties select Build.
5) Set the Optimize Code drop down to False.
6) Rebuild and then debug.
st**********@hotmail.com wrote:
Hi,

I'm doing a algorithm to calcule Earliest Start et Latest Start for a
Graph with Nodes and Arcs. (like a PERT diagram) . Unfortunatly, i
receive a wierd exception message for a specific generic (LIST<T>)

This method is calculed often before is put in a foreach statement. At
the first iterration, all is ok. But at the seond, I receive "Cannot
evaluate expression because the code of the current method is
optimized."

His someone can help me ? Here's my code.

Steeve

public void SetEarliestStart()
{
foreach (Node n in _NodeList)
{
n.Visited = false;
n.EarliestStart = 0;
n.Max = 0;
}

//Start Node
_NodeList[0].Visited = true;
_NodeList[0].EarliestStart = 0;

bool AllPrecVisited;
while(_NodeList[_NodeList.Count-1].Visited != true)
{
List<NodeNoneVisitedNodes = new List<Node>();
NoneVisitedNodes = _NodeList.FindAll(delegate(Node
node) //Exception is throw here !!

{

return node.Visited == false;

});
foreach(Node n in NoneVisitedNodes)
{
AllPrecVisited =
n.NodePrecList.TrueForAll(delegate(Node node)

{

return node.Visited == true;

});
if (AllPrecVisited)
{
foreach (Arc a in n.ArcPrecList)
{
if (n.Max < a.NodeStart.EarliestStart +
a.MoveTime
+
a.WorkTime)
{
n.Max = a.NodeStart.EarliestStart +
a.MoveTime + a.WorkTime;
}
}
n.EarliestStart = n.Max;
n.Visited = true;
break;

}
}
}
}
Sep 5 '06 #2
This property is already to false for my project. Is the problem can
come from another source ?
Can i code my method differently to avoid this error message?

Thanks.
Your Code is set to Optimize. In this mode, the compiler does code
optimizations any can sometimes not be able to debug.

Solution is to disable Optimizations while debugging.
1) Open the project properites from the Solution Explorer by right
clicking and selecting Properties
2) The Project Properties Dialog is shown.
3) Select your configuration from the Configuration Drop Down Box.
4) Under Configuration Properties select Build.
5) Set the Optimize Code drop down to False.
6) Rebuild and then debug.
Sep 6 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Zeng | last post by:
Hello, I just wonder if there is a way to programmatically evaluate expression strings such as ( ( 3 + 5 ) / 2 ) > 4 --> this should return 0 or false ( ( 3 + 6 ) / 3 ) > ( ( 5 + 3 ) / 4 ) ...
1
by: mark | last post by:
In the sample code for Programming Microsoft Visual Basic.NET by Francesco Balena (Microsoft Press) there is a program (ExprEvaluator) that evaluates expressions. It has a bug in that when the...
0
by: Rick Little | last post by:
While stepping through code, I've started getting this message when tying to see the value of most variables. Cannot evaluate expression because a thread is stopped at a point where garbage...
0
by: Ajit Goel | last post by:
Hi; My project file property is set to use "Visual Studio Development Server". I am able to debug and see the corresponding values when I mouseover but as soon as I change to the project file...
4
by: Glenn | last post by:
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...
2
by: tbh | last post by:
in an error path in an aspx script under DotNet 2, IIS6, Win2003 Server I get the following error (which I don't understand) on Respone.End(): {Unable to evaluate expression because the code is...
5
by: (2b|!2b)==? | last post by:
I get this error: The out parameter 'errMsg' must be assigned to before control leaves the current method when compiling the following code: public void ExecuteCommands(DDLCommands...
1
by: John A Grandy | last post by:
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...
16
by: jagdeep gupta | last post by:
The code was executing fine but now an exception is generated: "exc = {Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.}" ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.