PC Review


Reply
Thread Tools Rate Thread

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

 
 
steevehetu18@hotmail.com
Guest
Posts: n/a
 
      4th Sep 2006
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<Node> NoneVisitedNodes = 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;

}
}
}
}

 
Reply With Quote
 
 
 
 
DaanishRumani
Guest
Posts: n/a
 
      5th Sep 2006
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.


(E-Mail Removed) 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<Node> NoneVisitedNodes = 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;
>
> }
> }
> }
> }


 
Reply With Quote
 
Steeve
Guest
Posts: n/a
 
      6th Sep 2006
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.
>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
unable to evaluate expression because the code is optimized or native frame is on top of the call stack ED Microsoft Dot NET Compact Framework 3 11th Apr 2009 02:40 AM
Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack. Les Caudle Microsoft C# .NET 1 9th Dec 2008 10:24 AM
Cannot evaluate expression... optimized? Glenn Microsoft C# .NET 4 25th Apr 2007 06:20 PM
Unable to see value in Watch. Message: "Cannot evaluate expression because the code of the current m Ajit Goel Microsoft ASP .NET 0 16th Apr 2007 09:59 PM
Unable to see value in Watch. Message: "Cannot evaluate expression because the code of the current m Ajit Goel Microsoft ASP .NET 0 16th Apr 2007 09:57 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:37 AM.