tags:

views:

142

answers:

4

I am programming in C#; the code was working about a week ago, however it throws an exception and I don't understand at all what could be wrong with it.

Var root = new CalculationNode(); -> Throw exception.

In the call stack thats the only thing listed, I've been told that it could be that I need a clean build, but I am open to any ideas or suggestions.

Thanks, -Bill

Update: Exception's Detail

System.InvalidOperationException was unhandled by user code Message=Operation is not valid due to the current state of the object. Source=Calculator.Logic StackTrace: at ~.Calculator.Logic.MyBaseExpressionParser.Parse(String expression) in ~\Source\Calculator.Logic\MyBaseExpressionParser.cs:line 44 at ~.Calculator.Logic.Tests.MyBaseCalculatorServiceTests.BasicMathDivision() in ~\Projects\Tests\Calculator.Logic.Tests\MyBaseCalculatorServiceTests.cs:line 60 InnerException:

CalculationNode's code:

public sealed calss CalculationNode
{
 public CalculationNode()
{
this.Left = null;
this.Right = null;
this.Element = new CalculationElement();
}

public CalculationNode Left {get;set;}

public CalculationNode Right {get;set;}

public CalculationElement Element {get; set;}
}

CalculationElement's code:

public sealed class CalculationElement
{
 public CalculationElement()
{
Value = string.Empty;
IsOperator = false;
}

public string Value {get; set}

public bool IsOperator {get; set}
}
+1  A: 

First place to look would be in the constructor code of CalculationNode. You could set a breakpoint in that constructor and step through the code and see what problem is occurring.

If you are doing any type of logging, using a tool like log4net, you should check any logs you may have.

And as already mentioned, it's always a good idea to look at the stack trace to see if that sheds any light.

dcp
A: 

If you recently updated a service pack, You may need to update a database Schema.

Gnostus
There is no database involved here.
SLaks
then pay no mind to that solution :D
Gnostus
A: 

Your Calculator.Logic.MyBaseExpressionParser.Parse method is throwing an exception at line 44.

You should look at the method and figure out what the problem is.

SLaks
Thanks, I see what was wrong it turned out was a simple logic error with my validation method.
A: 

It looks like either Calculator.Logic.MyBaseExpressionParser.Parse, which is throwing the exception, is called somewhere else in your code, and it only looks like that line is causing the exception. Perhaps you're debugging into a version of the exe that is not the most current version of the code, or there's another thread executing Parse.

Marc Bollinger