【发布时间】:2014-02-18 17:02:35
【问题描述】:
我在本地 iis 中部署 asp mvc web 应用程序确实可以正常工作,但是当我移动到另一个 iis 时开始抛出以前未抛出的异常,我不知道配置中是否存在 nmatching。
DateTime date_deb = DateTime.ParseExact(_date_deb, "dd/MM/yyyy", null);
DateTime date_fin = DateTime.ParseExact(_date_fin, "dd/MM/yyyy", null);
[FormatException:字符串未被识别为有效的 DateTime。] System.DateTimeParse.ParseExact(String s, 字符串格式, DateTimeFormatInfo dtfi,
DateTimeStyles 风格)+3200706 System.DateTime.ParseExact(String s, String format, IFormatProvider provider) +31
//这里有其他异常
IList<object[]> bilansMois = session.CreateSQLQuery(sql).List<object[]>();
bilansMois[0].Count() != 0
[ArgumentOutOfRangeException:索引超出范围。一定是 非负和更少 比集合的大小。 参数名称:索引] System.ThrowHelper.ThrowArgumentOutOfRangeException() +72 System.Collections.Generic.List`1.get_Item(Int32 index) +9593284
【问题讨论】:
-
这与系统的文化有关,即服务器 1 是美国文化,服务器 2 可能是英国文化。请记住,您应该在您的应用中标准化您的日期时间构造以避免此类问题
-
日期问题还是秒解决
-
我做到了:DateTime date_deb = DateTime.ParseExact(_date_deb, "dd/MM/yyyy", CultureInfo.InvariantCulture);: 但 IList 仍然存在问题
-
很简单。您没有得到任何数据,因此该集合没有项目......但您试图引用集合中不存在的项目。始终在访问对象之前检查对象,以查看在访问项目之前是否有项目。永远不要认为您将永远拥有数据
-
也许非常感谢,我会试试的,谢谢
标签: c# asp.net-mvc iis