仅在WPF应用程序中使用WCF WSDualHttpBinding时遇到问题。在更改之前,此 WCF 有效。现在不工作了。我只将 ServiceBehavior(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!GXClientMainModuleTracking.DesktopService ReferencesGXServiceReference.cs:line 6274
at Main.ViewModels.LogOnWindowViewModel.BaseFW_OnGetServerItemsCompleted(Object sender, GetServerItemsCompletedEventArgs e) in d:Projects!New!GXClientMain.SilverlightViewModelsLogOnWindowViewModel.cs:line 208
at MainModuleTracking.GXService.MainServiceClient.OnGetServerItemsCompleted(Object state) in d:Projects!New!GXClientMainModuleTracking.DesktopService ReferencesGXServiceReference.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!GXClientMainModuleTracking.DesktopService ReferencesGXServiceReference.cs:line 8802
at MainModuleTracking.GXService.MainServiceClient.OnEndGetServerItems(IAsyncResult result) in d:Projects!New!GXClientMainModuleTracking.DesktopService ReferencesGXServiceReference.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();
看起来您的 WCF 调用超时,因为您已将 WCF 服务器(实质上(设置为单一访问。如果同时对服务有多个调用,则 WCF 服务一次处理一个调用,并且在超时时间很短的情况下,其中一些调用超时也就不足为奇了。
你能解释一下为什么你改变了你的并发模式吗?
我不知道怎么做,但问题在一段时间后得到解决。我认为问题在于缺少更新。现在,我尝试在VS2013中使用,并在构建后完美运行(并且没有VS2013(。