我目前正在开发 Windows Azure 服务,并且必须实现从 Exchange 服务器导入某些项目。 当我在本地模拟器上测试时,一切正常,我可以导入项目,但部署在云上时它停止工作。
这是我得到的异常:
Exception type: ServiceResponseException Exception message: An internal server error occurred. The operation failed.
我使用的代码:
service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.UseDefaultCredentials = false;
service.Credentials = new NetworkCredential(userName, password, domain);
service.Url = new Uri(serverUrl);
itemPropertySet = new PropertySet(BasePropertySet.FirstClassProperties);
itemPropertySet.RequestedBodyType = BodyType.Text;
CalendarView calendarView = new CalendarView(fromDate, toDate);
List<ExchangeTask> tasks = new List<ExchangeTask>();
try
{
FindItemsResults<Appointment> appointments = service.FindAppointments(WellKnownFolderName.Calendar, calendarView);
if (appointments.TotalCount > 0)
{
service.LoadPropertiesForItems(appointments, itemPropertySet);
}
foreach (Appointment app in appointments)
{
tasks.Add(new ExchangeTask() { Name = app.Subject, Description = app.Body, DeadLine = app.End.ToString() });
}
return tasks;
}
catch (Exception ex)
{
throw ex;
}
编辑 1: 这不是防火墙问题,因为如果我输入的用户名或密码不正确,它会抛出未经授权的异常,因此它会连接到服务器。
最佳答案
经过三天的痛苦,我解决了这个问题。问题是我没有在 ExchangeService
类的构造函数中指定时区。我的构造函数现在看起来像这样:
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1, TimeZoneInfo.FindSystemTimeZoneById("东部标准时间"));
关于c# - EWS 无法在 Windows Azure 上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15784227/