異常消息返回:我該如何解決這種異常? ArgumentOutOfRangeException
年,月,日和參數 描述一個未表示的日期時間。
例外打monthCalendar1.SelectionStart
DateTime check_date = monthCalendar1.SelectionStart;
for (int index = 0; index <= 5; index++)
{
check_date = new DateTime(check_date.Year, check_date.Month, check_date.Day - index);
}
我也試過這一個。但另外的異常已發生TargetInvocationException
DateTime check_date = monthCalendar1.SelectionStart;
for (int index = 0; index <= 5; index++)
{
check_date = check_date.AddDays(-index);
}
異常詳細信息:
System.ArgumentOutOfRangeException了未處理 消息=年,月,日和參數描述的未表示的日期時間。 源= mscorlib程序 堆棧跟蹤: 在System.DateTime.DateToTicks(的Int32年的Int32月的Int32日) 在System.DateTime..ctor(的Int32年的Int32月的Int32日) 在TestGetDates.Program.Main(字符串[] args)在C:\ Documents and Settings \ ngd11 \ My Documents \ Visual Studio 2010 \ Projects \ TestGetDates \ TestGetDates \ Program.cs:行15 at System.AppDomain._nExecuteAssembly(Assembly assembly,String [] args) 在System.AppDomain.ExecuteAssembly(字符串assemblyFile,證據assemblySecurity,字串[] args) 在Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 在System.Threading.ThreadHelper.ThreadStart_Context(對象狀態) 在的System.Threading .ExecutionConte xt.Run(執行上下文的ExecutionContext,ContextCallback回調,對象狀態) 在System.Threading.ThreadHelper.ThreadStart() 的InnerException:
僅供參考,使用自定義DateFormat(如「MM/yyyy」)時,在**本機Win32 DateTimePicker **中存在一個錯誤。 請參閱[這裏](http://connect.microsoft.com/VisualStudio/feedback/details/553375/system-argumentoutofrangeexception-year-month-and-day-parameters-describe-an-un-representable-datetime)描述。 並且有一個解決方法[這裏](http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/69b10b5b-a034-426e-a045-2bed8a1637a3) – itsho 2012-07-31 18:44:00