【问题标题】:Hosting WCF service in IIS cause an error "Showing a modal dialog box or form when the application..."在 IIS 中托管 WCF 服务会导致错误“在应用程序...时显示模式对话框或表单”
【发布时间】:2014-07-18 07:07:22
【问题描述】:

错误:当应用程序未在 UserInteractive 模式下运行时显示模式对话框或表单不是有效操作。指定 ServiceNotification 或 DefaultDesktopOnly 样式以显示来自服务应用程序的通知。

我看到这个错误已经在 StackOverflow 和其他网站上发布了很多。 但他们都想在他们的服务中显示 MessageBox 或 DialogBox。

我还没有编写任何代码行来在我的 WCF 服务中显示表单或消息框。

我还看到有人说这个错误可能是因为您的服务中发生了内部错误,并且因为它想显示错误消息,所以您会收到这个错误。我认为这在我的情况下更有可能,因为我在自己的计算机(即 Windows 7)中托管了我的 WCF 服务,没有任何问题。它工作正常。但是,当我在具有完全相同配置的生产环境(即 Windows Server 2008)中托管服务时,出现此错误。

如何查看我的服务中的问题?想要显示的对话框是什么?

更新:

服务器堆栈跟踪:在 System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(消息 回复、MessageFault 故障、字符串操作、MessageVersion 版本、 故障转换器故障转换器)在 System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime 操作,ProxyRpc& rpc) 在 System.ServiceModel.Channels.ServiceChannel.Call(字符串动作, Boolean oneway, ProxyOperationRuntime 操作, Object[] ins, Object[] 出局,TimeSpan 超时)在 System.ServiceModel.Channels.ServiceChannel.Call(字符串动作, Boolean oneway, ProxyOperationRuntime 操作, Object[] ins, 对象 [] 出局)在 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall,ProxyOperationRuntime 操作)在 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage 留言)

在 [0] 处重新抛出异常:在 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg)在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(消息数据& msgData,Int32 类型)在 Khorramshahr_Ins.FingerPrintWebService.IIdentifyFingerPrint.IdentifyFinger(IdentifyFingerRequest 请求)在 Khorramshahr_Ins.FingerPrintWebService.IdentifyFingerPrintClient.IdentifyFinger(IdentifyFingerRequest 请求)在 C:\PROJECTS\Production V1.0\ImportExport\Production V1\Fermat.ImportExport.Presentation\Service References\FingerPrintWebService\Reference.vb:第 328 行,位于 Khorramshahr_Ins.frmDeliverDocuments.Callback(IAsyncResult ar) 在 C:\PROJECTS\Production V1.0\ImportExport\Production V1\Fermat.ImportExport.Presentation\Operator\frmDeliverDocuments.vb:line 63 在 Khorramshahr_Ins.frmDeliverDocuments.btnVerify_Click(对象 发件人,EventArgs e) 在 C:\PROJECTS\Production V1.0\ImportExport\生产 V1\Fermat.ImportExport.Presentation\Operator\frmDeliverDocuments.vb:line 47 在 System.Windows.Forms.Control.OnClick(EventArgs e) 在 System.Windows.Forms.Button.OnClick(EventArgs e) 在 System.Windows.Forms.ButtonBase.OnKeyUp(KeyEventArgs kevent) 在 System.Windows.Forms.Control.ProcessKeyEventArgs(Message& m) 在 System.Windows.Forms.Control.ProcessKeyMessage(Message& m) 在 System.Windows.Forms.Control.WmKeyChar(Message& m) 在 System.Windows.Forms.Control.WndProc(Message& m) 在 System.Windows.Forms.ButtonBase.WndProc(Message& m) 在 System.Windows.Forms.Button.WndProc(Message& m) 在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(消息& m) 在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(消息& m) 在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(味精和味精)
在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID,Int32 原因,Int32 pvLoopData)在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 原因,ApplicationContext 上下文)在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 原因,ApplicationContext 上下文)在 System.Windows.Forms.Application.RunDialog(Form form) 在 System.Windows.Forms.Form.ShowDialog(IWin32Window 所有者)在 System.Windows.Forms.Form.ShowDialog() 在 Khorramshahr_Ins.TotalListWindow.btnDeliverDocuments_OnClick(对象 发件人,EventArgs e) 在 C:\PROJECTS\Production V1.0\ImportExport\生产 V1\Fermat.ImportExport.Presentation\Report\TotalListWindow.xaml.vb:line 185 在 System.Windows.Forms.Control.OnClick(EventArgs e) 在 System.Windows.Forms.Button.OnClick(EventArgs e) 在 增强型GlassButton.GlassButton.OnClick(EventArgs e) 在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs 事件) 在 增强型GlassButton.GlassButton.OnMouseUp(MouseEventArgs e) 在 System.Windows.Forms.Control.WmMouseUp(消息和 m,鼠标按钮 按钮,Int32 点击)在 System.Windows.Forms.Control.WndProc(Message& m) 在 System.Windows.Forms.ButtonBase.WndProc(Message& m) 在 System.Windows.Forms.Button.WndProc(Message& m) 在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(消息& m) 在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(消息& m) 在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 在 MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) 在 System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame 帧)在 System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame 框架)
在 System.Windows.Window.ShowHelper(Object booleanBox) 在 System.Windows.Window.Show() 在 System.Windows.Window.ShowDialog()

【问题讨论】:

  • IdentifyFinger(...) 方法肯定会打开一个对话框,要求用户将手指放在某个传感器上。您是否在 Windows 7 机器上的 IIS 中托管了相同的服务?
  • 不!正如我所说,它没有打开任何对话框。是的,它可以在我自己的 Windows 7 机器的 IIS 上运行
  • 可能是不同的指纹硬件或驱动程序?
  • 手指/加密狗的驱动程序/自制包装可能会显示一些对话框,因为加密狗显然是为桌面应用程序设计的。您可能需要检查调用堆栈或将其发布在此处,以便我们可能找到解决方案/解决方法以捕获错误,而无需让加密狗驱动程序显示对话框。更糟糕的情况是您可能不得不寻找另一个不那么粗鲁的加密狗。
  • @AndyH 它没有加密狗。它只有一个许可证文件,我也安装了它。我添加了堆栈跟踪

标签: c# .net wcf iis


【解决方案1】:

显然,您的代理服务调用的这个 FingerPrintWebService 支持回调。

C:\PROJECTS\Production V1.0\ImportExport\Production V1\Fermat.ImportExport.Presentation\Service References\FingerPrintWebService\Reference.vb:C:\PROJECTS 中 Khorramshahr_Ins.frmDeliverDocuments.Callback(IAsyncResult ar) 的第 328 行\Production V1.0\ImportExport\Production V1\Fermat.ImportExport.Presentation\Operator\frmDeliverDocuments.vb:第 63 行,位于

并且回调可能正在调用 WinForm 或对话框——这又需要消息泵,这在服务中很奇怪。

它在 Win7 上工作可能是因为在 Win7 上它没有通过这个调用堆栈运行;此外,Win7 和 Server 2008 有不同的默认设置。从Server 2008开始,MS对服务的安全性做了很多改动,特别是修复了一些服务调用UI的漏洞。

无论如何,您可能需要重新考虑您的整体设计。如果您想收到有关错误的警报,请使用 BCL 中的跟踪侦听器之一,例如 EventLogTraceListener,或 http://essentialdiagnostics.codeplex.com/ 中的其他跟踪侦听器

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-11
    • 2020-12-25
    • 2012-10-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多