本番環境でこのエラーが発生しています。何が原因なのか正確にはわかりません。
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)
{ }
}