【发布时间】:2014-05-28 10:28:01
【问题描述】:
我使用 EWS Managed API 2.1 并使用在我的 Win 2008 R2(德语)IIS 服务器上找到的所有系统时区初始化我的 ExchangeService,并使用最新的补丁级别:
EWS ews;
string s = "";
foreach (TimeZoneInfo tz in TimeZoneInfo.GetSystemTimeZones()) {
try {
ews = new ExchangeService(ExchangeVersion.Exchange2010, tz);
ews.Credentials = new WebCredentials("alex@contoso.com", "password");
ews.AutodiscoverUrl("alex@contoso.com");
Appointment app = new Appointment(ews);
app.Start = DateTime.Now;
app.End = DateTime.Now.AddMinutes(15);
app.Subject = tz.Id;
app.Save();
} catch(Exception ex) { s += ex.Message + "\n"; }
}
我收到一些时区错误。错误消息是:
Unable to convert 2009-01-01T00:00:00.000 from (UTC-03:00) Buenos Aires to UTC.
Unable to convert 2012-01-01T00:00:00.000 from (UTC-03:00) Salvador to UTC.
Unable to convert 2012-01-01T00:00:00.000 from (UTC+02:00) Tripolis to UTC.
Unable to convert 2009-01-01T00:00:00.000 from (UTC+04:00) Port Louis to UTC.
Unable to convert 2009-01-01T00:00:00.000 from (UTC+08:00) Perth to UTC.
谁能给我解释一下,尽可能简单,
- 为什么这些转换由 dll 代码尝试?
- 他们为什么会失败?
- 我是否/如何避免这个问题?
【问题讨论】:
-
当您的代码使用
DateTime.Now时,您如何收到 2009 年和 2012 年的错误消息? -
@MattJohnson 这正是我想知道的......
标签: c# timezone exchangewebservices ews-managed-api