指定的时区无效-使用服务器的EWS

本文关键字:服务器 EWS 无效 时区 | 更新日期: 2023-09-27 18:06:42

我从ASP.NET MVC应用程序在MS Exchange中设置了约会。

当我在乌克兰的电脑上运行代码时-一切正常,

但是当我在俄罗斯的服务器上部署我的代码时,它显示:

The specified time zone isn't valid.

我试了很多东西,但不能解决这个问题。请帮我解决这个问题。

我使用

:

Appointment Appointment = new Appointment(service);appointmet.Start;

指定的时区无效-使用服务器的EWS

如果有些人刚刚遇到同样的问题,它已被报告为EWS api中的问题(cf https://github.com/OfficeDev/ews-managed-api/issues/13),但似乎最有可能是。net TimeZoneInfo解析逻辑中的问题。. net版本的更新可能会修复它。

这对我有用:

static TimeZoneInfo getCorrectTimeZone()
{
  return TimeZoneInfo.CreateCustomTimeZone("Time zone to workaround a bug", TimeZoneInfo.Local.BaseUtcOffset, "Time zone to workaround a bug", "Time zone to workaround a bug");
}
static ExchangeService getExchangeService()
{
  var service = new ExchangeService(ExchangeVersion.Exchange2010_SP2, getCorrectTimeZone());
  return service;
}