5

本番環境でこのエラーが発生しています。何が原因なのか正確にはわかりません。

OnSubscriptionError : 
    Microsoft.Exchange.WebServices.Data.ServiceResponseException: 
       The specified subscription was not found.

ここで、開発環境での動作をシミュレートしたいと考えています。

  • イベントにサブスクライブしましたがConnection.OnSubscriptionError、イベント ハンドラーはOnSubscriptionError. 次に、ハンドラーをテストします。そのために、問題を抱えているイベントをトリガーする方法が必要です。

  • アプリケーションの実行中に交換ホスト サービスをシャットダウンしようとしましたが、OnsubscriptionError Event.

  • OnsubscriptionError eventが起動されたときに次のコードが機能するかどうかを知りたかったのです。または、接続を作成する前に Subscription オブジェクトを再作成する必要がありますか。

サンプルコードは次のとおりです。

Subscription =_exchangeService.SubscribeToStreamingNotifications(
                new FolderId[] { WellKnownFolderName.Inbox },
                EventType.NewMail);
CreateStreamingSubscription(_exchangeService, Subscription);

private void CreateStreamingSubscription(ExchangeService service,
                                         StreamingSubscription subscription)
{

    // public StreamingSubscriptionConnection(ExchangeService service, int lifetime) lifetime is in minutes and 30 mins is the maximum time till which
    // the connection can be open.
    Connection = new StreamingSubscriptionConnection(service, 30);
    Connection.AddSubscription(subscription);
    Connection.OnNotificationEvent += OnNotificationEvent;
    Connection.OnSubscriptionError += OnSubscriptionError;
    Connection.OnDisconnect += OnDisconnect;
    Connection.Open();
 }  
 private void OnSubscriptionError(object sender, SubscriptionErrorEventArgs args)
 {
    if (args.Exception is ServiceResponseException)
    {
        var exception = args.Exception as ServiceResponseException; 
    }
    else if (args.Exception !=null)
    {
        Logwriter.LogMsg(_clientInfo.LogId, LogLevel.FATAL,
                         "OnSubscriptionError() : " + args.Exception.Message +
                         " Stack Trace : " + args.Exception.StackTrace + 
                         " Inner Exception : " + args.Exception.InnerException);
    }
    try
    {
        Connection = (StreamingSubscriptionConnection)sender;
        if(!Connection.IsOpen)
            Connection.Open();
    }
    catch (ServiceResponseException exception)
    { }
    catch (Exception ex)
    { }
 }
4

2 に答える 2

3

接続によって起動されると、このOnSubscriptionError接続は何らかの形ですべてのサブスクリプションを失います。したがって、サブスクリプションがないため、接続を再度開くことはできません。個人的にサブスクリプションを再作成します。サブスクリプションをリストに入れて直接追加しようとしましたが、うまくいきませんでした。

于 2013-10-31T12:14:31.173 に答える