c# – 我创建的DateTime对象和DateTime.Now之间的差异

我正在尝试使用Exchange 2007 API查询特定用户的日历可用性.我的示例代码产生以下异常:

The time duration specified for FreeBusyViewOptions.TimeWindow is
invalid.

这是示例代码

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);

service.AutodiscoverUrl("email@domain.com");

DateTime startTime = new DateTime(2012,1,6,7,0);

TimeWindow tw = new TimeWindow(startTime,startTime.AddHours(8));

GetUserAvailabilityResults result = service.GetUserAvailability(new List<AttendeeInfo> { new AttendeeInfo("email@domain.com") },tw,AvailabilityData.FreeBusyAndSuggestions);

奇怪的是,如果我用以下内容替换我的startTime赋值它可以工作:

DateTime startTime = DateTime.Now;

我创建的DateTime对象与DateTime.Now生成的对象之间有什么区别.我在调试时仔细检查了它们,但找不到区别.

有任何想法吗?

解决方法

这实际上似乎是GetUserAvailability方法中的一个问题,而不是任何DateTime操作.

根据MSDN documentation

The GetUserAvailability(Generic,TimeWindow,AvailabilityData,AvailabilityOptions) method supports only time periods that are a minimum of 24 hours long and that begin and end at 12:00a.m. To restrict the results of the method to a shorter time period,you must filter the results on the client.

相关文章

在要实现单例模式的类当中添加如下代码:实例化的时候:frmC...
1、如果制作圆角窗体,窗体先继承DOTNETBAR的:public parti...
根据网上资料,自己很粗略的实现了一个winform搜索提示,但是...
近期在做DSOFramer这个控件,打算自己弄一个自定义控件来封装...
今天玩了一把WMI,查询了一下电脑的硬件信息,感觉很多代码都...
最近在研究WinWordControl这个控件,因为上级要求在系统里,...