C# Azure字符串未被识别为有效的DateTime

C# Azure字符串未被识别为有效的DateTime,c#,datetime,azure,C#,Datetime,Azure,有趣的是,下面的代码适用于我们的内部部署环境,但不适用于azure web角色 有人能给我指出我做错的方向吗 我们从第三方获取日期和时间作为字符串,并使用下面的逻辑进行解析 string givenDate="21/06/2013"; string givenTime="7:35 PM"; var givenDateTime = DateTime.Parse(givenDate + " " + givenTime, CultureInfo.InvariantCulture); 上述代码在Az

有趣的是,下面的代码适用于我们的内部部署环境,但不适用于azure web角色

有人能给我指出我做错的方向吗

我们从第三方获取日期和时间作为字符串,并使用下面的逻辑进行解析

string givenDate="21/06/2013";
string givenTime="7:35 PM";

var givenDateTime = DateTime.Parse(givenDate + " " + givenTime, CultureInfo.InvariantCulture);
上述代码在Azure中引发以下异常:

Exception: System.FormatException
Message: String was not recognized as a valid DateTime.

不变区域性使用US月/日/年格式

“d”标准格式说明符表示自定义日期和时间 格式化由特定区域性的 DateTimeFormatInfo.ShortDatePattern属性。例如,海关 由的ShortDatePattern属性返回的格式字符串 不变区域性为“MM/dd/yyyy”


你能试着改为
ParseExact
吗?我认为这与Azure-
DateTime.Parse没有任何关系(“21/06/2013 7:35 PM”,CultureInfo.InvariantCulture)
在任何地方都会失败。