我有一个大型项目,当我按下按钮时,我开始执行任务:
Task.Factory.StartNew(() =>
{
CreatePortfolio();
});
表单有一个MSChart,我有一个访问图表的方法的委托。
当我单步执行代码时,抛出NO ERROR。但是,当我运行它时,我收到此错误 - 但不知道它来自何处,因为它显示在下面的Application.Run行:
public static string[] MainArgs;
[STAThread]
static void Main(string[] args)
{
CheckForIllegalCrossThreadCalls = false;
MainArgs = args;
Application.Run( new MainForm( ) ); //ERROR shown here
}
和例外:
System.ArgumentOutOfRangeException was unhandled
HResult=-2146233086
Message=Years value must be between +/-10000.
Parameter name: years
Source=mscorlib
ParamName=years
StackTrace:
at System.DateTime.AddYears(Int32 value)
at System.Windows.Forms.DataVisualization.Charting.ChartHelper.GetIntervalSize(Double current, Double interval, DateTimeIntervalType type, Series series, Double intervalOffset, DateTimeIntervalType intervalOffsetType, Boolean forceIntIndex, Boolean forceAbsInterval)
at System.Windows.Forms.DataVisualization.Charting.ChartHelper.GetIntervalSize(Double current, Double interval, DateTimeIntervalType type, Series series, Double intervalOffset, DateTimeIntervalType intervalOffsetType, Boolean forceIntIndex)
at System.Windows.Forms.DataVisualization.Charting.Axis.FillLabels(Boolean removeFirstRow)
at System.Windows.Forms.DataVisualization.Charting.ChartArea.SetDefaultAxesValues()
at System.Windows.Forms.DataVisualization.Charting.ChartArea.SetData(Boolean initializeAxes, Boolean checkIndexedAligned)
at System.Windows.Forms.DataVisualization.Charting.ChartArea.ReCalcInternal()
at System.Windows.Forms.DataVisualization.Charting.ChartPicture.Paint(Graphics graph, Boolean paintTopLevelElementOnly)
at System.Windows.Forms.DataVisualization.Charting.Chart.OnPaint(PaintEventArgs e)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
InnerException:
答案 0 :(得分:1)
我认为您在某些时候使用DateTime.AddYears并且传递给添加年份的值无效。
请检查我认为您正在使用某个数组并从该数组的某个索引传递值,并且在某一点上传递的数组不可用。这是你的问题