EWS托管API 2.2 StreamingSubscription异常

时间:2017-02-21 12:57:54

标签: c# exchangewebservices ews-managed-api

我遵循Microsoft的指导,开发了一个使用StreamingSubscription的应用程序。它工作,但我总是得到一个System.ArgumentNullException 在以下代码上。

 ExchangeService srv = new ExchangeService(ExchangeVersion.Exchange2010_SP2);

        //service.AutodiscoverUrl("xx.xx@xxxx.nl");
        srv.Credentials = new WebCredentials("xxx", "xxx", "xxx");           
        srv.Url = new Uri("https://xx.xx.nl/ews/exchange.asmx");

        FolderId gpInbox = new FolderId(WellKnownFolderName.Inbox, new Mailbox("xx.xx@xxxx.nl"));

        // Subscribe to streaming notifications in the Inbox. 
        StreamingSubscription sss = srv.SubscribeToStreamingNotifications(
            new FolderId[] { WellKnownFolderName.Inbox },
            EventType.NewMail);

        StreamingSubscriptionConnection c = new StreamingSubscriptionConnection(srv, 30);
        {
            c.AddSubscription(sss);
            c.OnNotificationEvent += OnNotificationEvent;
            c.OnDisconnect += OnDisconnect;
            c.Open();
        }

抛出异常
StreamingSubscription sss = srv.SubscribeToStreamingNotifications(
            new FolderId[] { WellKnownFolderName.Inbox },
            EventType.NewMail);

我无法找到导致异常的原因。我已经通过Nuget包

安装了最新版本的API

1 个答案:

答案 0 :(得分:2)

要获取最新版本的EWS托管API,您需要从GitHub https://github.com/OfficeDev/ews-managed-api编译它.NuGet版本相当陈旧,并且自公开发布源代码以来尚未更新。订阅中有许多问题已修复https://github.com/OfficeDev/ews-managed-api/issues?page=1&q=is%3Aissue+is%3Aclosed&utf8=%E2%9C%93(以及未列出的其他订阅)可能是原因或您的问题。