【问题标题】:WSDualHttpBinding in WPF not respondingWPF 中的 WSDualHttpBinding 没有响应
【发布时间】:2013-10-10 05:14:10
【问题描述】:

我在 WPF 应用程序中使用 WCF WSDualHttpBinding only 时遇到问题。在更改之前,此 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();

【问题讨论】:

    标签: wpf wcf wsdualhttpbinding servicebehavior instancecontextmode


    【解决方案1】:

    看起来您的 WCF 调用超时了,因为您已将 WCF 服务器(本质上)设置为单一访问。如果您同时对服务进行多次调用,您的 WCF 服务会一次处理一个,并且在您的超时时间很短的情况下,其中一些超时也就不足为奇了。

    您能解释一下为什么要更改并发模式吗?

    【讨论】:

    • 我更改了 ConcurenncyMode,因为我需要为每个客户端一个会话一个实例。我试图同时调试(客户端和 WCF)。在客户端调用一种方法后,在客户端上创建 WCF 实例。此方法产生异常 - WCF 没有响应。
    • 好的,我做了一个小应用程序来说明问题。应用程序在 zip 中 https://drive.google.com/folderview?id=0BxB1L_GOpVflbk1VMTdZRDdZOUU&usp=sharing 在默认状态下 - 工作。如果您将 clientBaseAddres 更改为您的本地地址,例如 192.168.1.1 应用程序停止工作。那么问题出在哪里?
    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-12
      • 1970-01-01
      • 1970-01-01
      • 2019-03-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多