0

我仅在 WPF 应用程序中使用 WCF WSDualHttpBinding 时遇到问题。在更改之前,此 WCF 有效。现在不工作了。我仅将 ServiceBehaviour(ConcurrencyMode 和 InstanceContextMode)更改为:

[ServiceBehavior(IncludeExceptionDetailInFaults = true, ConcurrencyMode = ConcurrencyMode.Reentrant, InstanceContextMode = InstanceContextMode.PerSession)]

之后,WCF 没有响应,请参阅异常详细信息。有任何想法吗?

System.Reflection.TargetInvocationException was unhandled by user code
  HResult=-2146232828
  Message=An exception occurred during the operation, making the result invalid.  Check InnerException for exception details.
  Source=System
  StackTrace:
       at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
       at MainModuleTracking.GXService.GetServerItemsCompletedEventArgs.get_Result() in d:\Projects\!New!\GXClient\MainModuleTracking.Desktop\Service References\GXService\Reference.cs:line 6274
       at Main.ViewModels.LogOnWindowViewModel.BaseFW_OnGetServerItemsCompleted(Object sender, GetServerItemsCompletedEventArgs e) in d:\Projects\!New!\GXClient\Main.Silverlight\ViewModels\LogOnWindowViewModel.cs:line 208
       at MainModuleTracking.GXService.MainServiceClient.OnGetServerItemsCompleted(Object state) in d:\Projects\!New!\GXClient\MainModuleTracking.Desktop\Service References\GXService\Reference.cs:line 8818
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.DispatcherOperation.InvokeImpl()
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Windows.Threading.DispatcherOperation.Invoke()
       at System.Windows.Threading.Dispatcher.ProcessQueue()
       at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
       at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
       at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       at System.Windows.Window.ShowHelper(Object booleanBox)
       at System.Windows.Window.ShowDialog()
  InnerException: System.TimeoutException
       HResult=-2146233083
       Message=Opening the http://192.168.7.104:8181/WpfMainService channel timed out after 00:01:00. The time allotted to this operation may have been a portion of a longer timeout.
       Source=mscorlib
       StackTrace:
         Server stack trace:
            at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
            at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
            at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
            at System.ServiceModel.Channels.ServiceChannelProxy.InvokeEndService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
            at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
         Exception rethrown at [0]:
            at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
            at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
            at MainModuleTracking.GXService.IMainService.EndGetServerItems(IAsyncResult result)
            at MainModuleTracking.GXService.MainServiceClient.EndGetServerItems(IAsyncResult result) in d:\Projects\!New!\GXClient\MainModuleTracking.Desktop\Service References\GXService\Reference.cs:line 8802
            at MainModuleTracking.GXService.MainServiceClient.OnEndGetServerItems(IAsyncResult result) in d:\Projects\!New!\GXClient\MainModuleTracking.Desktop\Service References\GXService\Reference.cs:line 8810
            at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)
       InnerException: 

编辑

callbackService = new ServiceCallback();
InstanceContext context = new InstanceContext(callbackService);
mainService = new MainServiceClient(context, "WSDualHttpBinding_IMainService");
mainService.SubscribeErrorsAsync();
mainService.GetServerItemsAsync();
4

2 回答 2

0

Looks like your WCF call is timing out because you have set your WCF server (to essentially) Single access. If you have multiple calls to the service at the same time, your WCF service processes them one at a time, and with your very short timeout, its not surprising that some of them timeout.

Could you explain WHY you changed your ConcurrencyMode?

于 2013-10-10T05:38:15.007 回答
0

我不知道如何,但问题在一段时间后解决了。我认为问题在于缺少更新。现在,我尝试在 VS2013 中使用,并且在构建后一切正常(并且没有 VS2013)。

于 2013-12-04T13:51:31.350 回答