
下面是我用来初始化订阅和我使用的事件的代码.
public voID Subscribe(){ var locateMailBox = new MailBox { Address = "myemail" }; var folderID = new FolderID(WellKNownFoldername.InBox,locateMailBox); var foldersToWatch = new[] {folderID}; StreamingSubscription streamingSubscription = _exchangeService.SubscribetoStreamingNotifications(foldersToWatch,EventType.NewMail); // Timeout is set at 1 minute intentionally var streamingConnection = new StreamingSubscriptionConnection(_exchangeService,1); streamingConnection.AddSubscription(streamingSubscription); streamingConnection.OnSubscriptionError += ResolveError; streamingConnection.Ondisconnect += Reconnect; streamingConnection.open();}public voID Reconnect(object sender,SubscriptionErrorEventArgs disconnectEventArgs){ if (!((StreamingSubscriptionConnection)sender).IsOpen) ((StreamingSubscriptionConnection)sender).open();}public voID ResolveError(object sender,SubscriptionErrorEventArgs errorEventArgs){ var streamingSubscriptionConnection = (StreamingSubscriptionConnection) sender; if (!streamingSubscriptionConnection.IsOpen) streamingSubscriptionConnection.open();} ServiceLocalException – 必须先为此连接添加至少一个订阅,然后才能打开它.
这个例外不言而喻,我知道我可以简单地在Reconnect()中创建另一个订阅.我希望有人能帮我理解订阅的去向.我无法想象像Exchange 2010这样的产品会丢失我的订阅.另外,我无法指出错误.有时候我可以让我的订阅保持活动状态10分钟,有时我会收到一条关于我的订阅在2-3分钟后无效的错误.
我使用Exchange 2010 SP1是值得的.
解决方法 通过查看Reflector中的源代码,看起来只有两种方式可以删除订阅(除了处理StreamingSubscriptionConnection,通过调用Remove,我假设你没有做,或者通过订阅返回错误代码其他您可以通过查看ResolveError处理程序中的errorEventArgs.Exception来检查错误.如果它是ServiceResponseException的实例,则将其强制转换为该类型并获取ErrorCode属性.在触发OnSubscriptionError事件后,订阅是然后自动删除.获取错误代码可能会帮助您找出发生这种情况的原因,但即使您无法修复它,您也可以确定何时删除订阅并在此情况下异步添加其他订阅.
总结以上是内存溢出为你收集整理的c# – 我的流媒体订阅在哪里?全部内容,希望文章能够帮你解决c# – 我的流媒体订阅在哪里?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)