Reputation: 634
I am getting this error and I do not know why:
'-1.4210854715202E-14' is not a valid value for property 'Height'
It pops out as a message box. After I click ok, the message box is gone. When I step in, track it back in the source code where it happens, there is no error, and the message box did not show up at all.
This really bothers me: where does the problem occur and how can I trace it?
Some source code:
public ICommand SetZScanStartCommand
{
get
{
if (this._setZScanStartCommand == null)
this._setZScanStartCommand = new RelayCommand(() => SetZScanStart());
return this._setZScanStartCommand;
}
}
Then:
private void SetZScanStart()
{
_zScanStart = this._liveImage.ZPosition;
_zRangeMin = this._liveImage.ZPosition;
OnPropertyChanged("ZRangeMin");
OnPropertyChanged("ZScanStart");
OnPropertyChanged("ZScanNumSteps");
OnPropertyChanged("ZScanThickness");
}
The SetZScanStartCommand() response to a button click that pass the value of a edit box. One The edit box gives the start point, and there is another edit box similarly gives the end point. The difference between start point and end point gives the length. We are computing the number of steps, which is defined as the length divided by step size; In our case, which crashes, start point is 6.6, end point is 1.0, step size of 0.5, so the number of the steps should be (6.6 - 1.0) / 0.5 = 11; Note it is rounded.
Upvotes: 1
Views: 1368
Reputation: 32561
I believe that this is related to a subtraction of some float
variables in your code.
I would look first at your float
variables, maybe replace them with another non-floating-point type, and see what happens.
Upvotes: 1