“/”应用程序中的服务器错误。

该字符串未被识别为有效的 DateTime。

说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.FormatException: 该字符串未被识别为有效的 DateTime。

源错误:


行 30:     public string DateFormat(string format, object dateline)
行 31:     {
行 32:         DateTime date = Convert.ToDateTime(dateline.ToString());
行 33:         return date.ToString(format);
行 34:     }

源文件: d:\wwwroot\yining\wwwroot\App_Code\Home\ArticleTemplate.cs    行: 32

堆栈跟踪:


[FormatException: 该字符串未被识别为有效的 DateTime。]
   System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) +11066810
   System.Convert.ToDateTime(String value) +83
   ArticleTemplate.DateFormat(String format, Object dateline) in d:\wwwroot\yining\wwwroot\App_Code\Home\ArticleTemplate.cs:32
   ArticleTemplate.DateFormat(Object dateline) in d:\wwwroot\yining\wwwroot\App_Code\Home\ArticleTemplate.cs:37

[MethodInvocationException: Invocation of method 'DateFormat' in  ArticleTemplate threw exception System.FormatException : 该字符串未被识别为有效的 DateTime。]
   NVelocity.Runtime.Parser.Node.ASTMethod.Execute(Object o, IInternalContextAdapter context) +977
   NVelocity.Runtime.Parser.Node.ASTReference.Execute(Object o, IInternalContextAdapter context) +447
   NVelocity.Runtime.Parser.Node.ASTReference.Render(IInternalContextAdapter context, TextWriter writer) +60
   NVelocity.Runtime.Parser.Node.SimpleNode.Render(IInternalContextAdapter context, TextWriter writer) +66
   NVelocity.Template.Merge(IContext context, TextWriter writer) +138
   Templates.Display(String templateName) in d:\wwwroot\yining\wwwroot\App_Code\Templates.cs:59
   Index.ArticleDetailPage() in d:\wwwroot\yining\wwwroot\index.aspx.cs:189

[TargetInvocationException: 调用的目标发生了异常。]
   System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
   System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +192
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +155
   System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) +19
   Index.Page_Load(Object sender, EventArgs e) in d:\wwwroot\yining\wwwroot\index.aspx.cs:114
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
   System.Web.UI.Control.OnLoad(EventArgs e) +92
   System.Web.UI.Control.LoadRecursive() +54
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772


版本信息: Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.0.30319.36480