IIS中显示未处理的异常--- UCMA应用程序 [英] Unhandled Exception is showing in IIS---UCMA Application
问题描述
我在WCF中开发了一个ucma应用程序,并在iis中部署,同时运行它显示未处理的异常。如果发生此异常,WCF也会停止工作其他线程。我检查了事件查看器,显示如下错误。
发生未处理的异常并且流程已终止。
申请ID:/ LM / 1 / ROOT / webchservice
进程ID:4028
异常:Microsoft.Rtc.Signaling.OperationFailureException
消息:当前对象状态(终止)中的操作无效。
StackTrace:在Microsoft.Rtc.Signaling。 Microsoft.Rtc.Signaling.Helper.EndAsyncOperation [T](对象所有者,IAsyncResult结果)中的SipAsyncResult`1.ThrowIfFailed()
在Microsoft.Rtc.Collaboration.InstantMessagingFlow.EndSend D:\ Final \InstantMessaging \ UCInstantMessageProvider中的Lync.Service.InstantMessaging.UCInstantMessageProvider.SendMessageCompleted(IAsyncResult结果)中的InstantMessageInternal(IAsyncResult结果)
。 cs:第399行
at Microsoft.Rtc.Signaling.WorkitemQueue.ProcessItems()
at Microsoft.Rtc.Signaling.SerializationQueue`1.ResumeProcessing()
at Microsoft.Rtc.Signaling.SerializationQueue`1.ResumeProcessingCallback(Object state) 强>
是在Microsoft.Rtc.Signaling.QueueWorkItemState.ExecuteWrappedMethod(WaitCallback方法,对象的状态)强>
System.Threading.Quereading.Quereading.serue.UutWorkUtemCallback.System上的System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback callback,Object state,Boolean ignoreSyncCtx)
.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
是在System.Threading.ThreadPoolWorkQueue.Dispatch()强>
是在System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()强>
InnerException:System.InvalidOperationException
消息:当前对象状态(终止)中的操作无效。
StackTrace:在Microsoft.Rtc.Collaboration.Call.BeginSendMessageInternal(SignalingDialogContext callDialogContext,MessageType messageType,ContentType contentType,Byte [] body,IEnumerable`1 signalingHeaders,Boolean useApplicationQueue ,AsyncCallback
userCallback,Object state)
at Microsoft.Rtc.Collaboration.ComponentModel.MediaProvider.BeginSendMessage(CallDialogContext signalingContext,MessageType messageType,ContentDescription message ,IEnumerable`1 messageHeaders,AsyncCallback userCallback,Object state)
at Microsoft.Rtc.Collaboration.InstantMessagingPr ovider.BeginSendCallMessage(CallDialogContext callContext,MessageType messageType,ContentDescription message,AsyncCallback userCallback,Object state)
at Microsoft.Rtc.Collaboration.InstantMessagingFlow.SendMessageAsyncResult.ProcessCoreHelper
我认为异常是从代码下面发生的
______________
私人无效InstantMessagingFlow_MessageReceived(对象发件人,InstantMessageReceivedEventArgs E)
   {
    _activityReceived =真; 跨度>
var message = e.TextBody;
_sessionStartTime = DateTime.Now;
if(_waitingForAcceptation)
{
if(message .ToLowerInvariant()==" accept")
{
OnChatRequestAcceptanceChanged(new ChatRequestAcceptanceChangedEventArgs (true));
$
}
else if(message.ToLowerInvariant()==" deny")
{
      OnChatRequestAcceptanceChanged(新ChatRequestAcceptanceChangedEventArgs(假));
    }
  &NBSP ; else
OnChatRequestAcceptanceChanged(new ChatRequestAcceptanceChangedEventArgs(true));
OnChatMessageReceivedFromLyncClient (new MessageReceivedFromLyncClientEventArgs(message));
$
{
}
_waitingForAcceptation = false;
}
else
    {
     OnChatMessageReceivedFromLyncClient(新MessageReceivedFromLyncClientEventArgs(消息));
   }
}
{
例外ex = null;
试试
{
      _instantMessagingFlow.EndSendInstantMessage(结果);
         _instantMessagingFlow.LocalComposingState = ComposingState.Idle;
  ;         if(_chatCloseRequested)
{
                    OnChatClosed(新的EventArgs());
                }
}
catch(OperationTimeoutException opTimeEx)
{
                   EX = opTimeEx;
Log.Error(QUOT; OperationTimeoutException-SendMessageComplete - >" ;, opTimeEx);
            } catch(InvalidOperationException opex)
{
OnInstantMessageProviderExceptionOccured(new InstantMessageProviderExceptionOccuredEventArgs(opex));
Log.Error(QUOT; InvalidOperation-SendMessageComplete - >" ;, OPEX);
            }
catch(RealTimeException rte)
{
                    &NBSP ;          Log.Error(QUOT; RealTimeException-SendMessageComplete - >" ;, RTE);
           &NBSP ;    ex = rte;
}
最后是
{
//重置本地最终用户的撰写状态,以便输入所示的输入通知
      //由远端客户端消失。
_instantMessagingFlow.LocalComposingState = ComposingState.Idle;
                if(ex!= null)
{
                    &NBSP ;                  
  &NBSP ;                 Log.Error(QUOT;平台关闭由于在方法SendMEssageComplete"误差;,购);
                     _helper.Dispose();
}
}
        }
________
能否请你帮我解决这个问题。这个例外不是每次都发生的,我不知道是什么原因。如果没有解决方案可以避免这种异常,我需要此异常不要阻止WCF服务中的其他方法
,目前如果发生此异常,则会发出警告说.netframe发生未处理的异常并停止执行WCF。请给出解决方案如何解决此问题?如何处理此异常?
在调用EndSendInstantMessage之前,看起来您的调用状态正在终止。如果您使用Lync Server Logging工具查看sip堆栈,可以找到这个的根本原因。
只是为了快速修复以避免错误检查流程调用状态在您之前。称之为  _instantMessagingFlow.EndSendInstantMessage(结果);
其像
的 <跨度风格="字体大小:小">
如果(_instantMessagingFlow.Call.State == CallState.Established){
_instantMessagingFlow.EndSendInstantMessage(结果);
}
这可能无法解决您的实际问题,但可以防止引发异常。
I have developed an ucma application in WCF and deployed in iis,while running it showing unhandled exception.And if this exception occurs WCF stops working other threads also.I checked in event viewer showing below error.
An unhandled exception occurred and the process was terminated.
Application ID: /LM/1/ROOT/webchservice
Process ID: 4028
Exception: Microsoft.Rtc.Signaling.OperationFailureException
Message: The operation is invalid in the current object state (Terminating).
StackTrace: at Microsoft.Rtc.Signaling.SipAsyncResult`1.ThrowIfFailed()
at Microsoft.Rtc.Signaling.Helper.EndAsyncOperation[T](Object owner, IAsyncResult result)
at Microsoft.Rtc.Collaboration.InstantMessagingFlow.EndSendInstantMessageInternal(IAsyncResult result)
at Lync.Service.InstantMessaging.UCInstantMessageProvider.SendMessageCompleted(IAsyncResult result) in D:\Final\InstantMessaging\UCInstantMessageProvider.cs:line 399
at Microsoft.Rtc.Signaling.WorkitemQueue.ProcessItems()
at Microsoft.Rtc.Signaling.SerializationQueue`1.ResumeProcessing()
at Microsoft.Rtc.Signaling.SerializationQueue`1.ResumeProcessingCallback(Object state)
at Microsoft.Rtc.Signaling.QueueWorkItemState.ExecuteWrappedMethod(WaitCallback method, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
InnerException: System.InvalidOperationException
Message: The operation is invalid in the current object state (Terminating).
StackTrace: at Microsoft.Rtc.Collaboration.Call.BeginSendMessageInternal(SignalingDialogContext callDialogContext, MessageType messageType, ContentType contentType, Byte[] body, IEnumerable`1 signalingHeaders, Boolean useApplicationQueue, AsyncCallback userCallback, Object state)
at Microsoft.Rtc.Collaboration.ComponentModel.MediaProvider.BeginSendMessage(CallDialogContext signalingContext, MessageType messageType, ContentDescription message, IEnumerable`1 messageHeaders, AsyncCallback userCallback, Object state)
at Microsoft.Rtc.Collaboration.InstantMessagingProvider.BeginSendCallMessage(CallDialogContext callContext, MessageType messageType, ContentDescription message, AsyncCallback userCallback, Object state)
at Microsoft.Rtc.Collaboration.InstantMessagingFlow.SendMessageAsyncResult.ProcessCoreHelper
I think exception is happening from below code
______________
private void InstantMessagingFlow_MessageReceived(object sender, InstantMessageReceivedEventArgs e)
{
_activityReceived = true;
var message = e.TextBody;
_sessionStartTime = DateTime.Now;
if (_waitingForAcceptation)
{
if (message.ToLowerInvariant() == "accept")
{
OnChatRequestAcceptanceChanged(new ChatRequestAcceptanceChangedEventArgs(true));
}
else if (message.ToLowerInvariant() == "deny")
{
OnChatRequestAcceptanceChanged(new ChatRequestAcceptanceChangedEventArgs(false));
}
else
OnChatRequestAcceptanceChanged(new ChatRequestAcceptanceChangedEventArgs(true));
OnChatMessageReceivedFromLyncClient(new MessageReceivedFromLyncClientEventArgs(message));
{
}
_waitingForAcceptation = false;
}
else
{
OnChatMessageReceivedFromLyncClient(new MessageReceivedFromLyncClientEventArgs(message));
}
}
private void SendMessageCompleted(IAsyncResult result)
{
Exception ex = null;
try
{
_instantMessagingFlow.EndSendInstantMessage(result);
_instantMessagingFlow.LocalComposingState = ComposingState.Idle;
if (_chatCloseRequested)
{
OnChatClosed(new EventArgs());
}
}
catch (OperationTimeoutException opTimeEx)
{
ex = opTimeEx;
Log.Error("OperationTimeoutException-SendMessageComplete-->", opTimeEx);
}catch(InvalidOperationException opex)
{
OnInstantMessageProviderExceptionOccured(new InstantMessageProviderExceptionOccuredEventArgs(opex));
Log.Error("InvalidOperation-SendMessageComplete-->", opex);
}
catch (RealTimeException rte)
{
Log.Error("RealTimeException-SendMessageComplete-->", rte);
ex = rte;
}
finally
{
// Reset the composing state of the local end user so that the typing notifcation as seen
// by the far end client disappears.
_instantMessagingFlow.LocalComposingState = ComposingState.Idle;
if (ex != null)
{
Log.Error("Shutting down platform due to error in method SendMEssageComplete",ex);
_helper.Dispose();
}
}
}
________
Can you please help me to solve this issue.This exception is not happen everytime,i dont know what the reason for this.If there is no solution to avoid this exception,i need this exception not to block other methods in WCF services,currently if this exception occur an alert comes saying .netframe occur unhandled exception and stops execeution WCF.Please give solution how to solve this?how to handle this exception?
It seems like your call state is terminating before you call EndSendInstantMessage. The root cause of this can be found if you look into sip stack using Lync Server Logging tool.
just for quick fix to avoid error check flow call state before you call this. _instantMessagingFlow.EndSendInstantMessage(result);
its like
if(_instantMessagingFlow.Call.State == CallState.Established){
_instantMessagingFlow.EndSendInstantMessage(result);
}
This may not solve your actual problem but prevents raising exception.
这篇关于IIS中显示未处理的异常--- UCMA应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!