Windows サービスで String が有効な DateTime 例外として認識されなかったが、コンソール アプリケーションで同じコードが正しく実行されている
Object max = cmd.ExecuteScalar(); //max will have 6/30/2012 12:00:00 AM
DateTime currentDt = DateTime.Now;
currentDt = DateTime.ParseExact(max.ToString(), "M/d/yyyy h:mm:ss tt", CultureInfo.CurrentCulture.DateTimeFormat); //This Line Gives Error in WindowsService Only
StreamWriter sw = new StreamWriter("E:\\ram\\SampleService.txt", true);
sw.WriteLine(currentDt.ToString());
sw.Close();
システムの DateTime 形式の設定を英語に変更しました。Us Settings.ShortDatetime は M/d/yyyy で、Longtime は h:mm:ss tt です。
誰かがこの問題を解決するのを手伝ってくれますか?