【问题标题】:Error message with WCF WSDualHttpBinding: Unable to automatically debug serviceWCF WSDualHttpBinding 的错误消息:无法自动调试服务
【发布时间】:2009-07-12 08:39:08
【问题描述】:

我目前正在研究一种解决方案,该解决方案需要同时使用 Silverlight 3.0 和标准 .NET 应用程序作为使用 WCF 实现的 Web 服务的客户端。 Silverlight 客户端使用的 Web 服务部分需要双工功能,因此我在服务的一个端点上使用(仍然相当新的)PollingDuplexBindingElement。但是,PDBE 仅受 Silverlight 支持,因此我为其他客户端的服务添加了第二个端点,它使用 WSDualHttpBinding 作为绑定。这些其他客户端实际上并不需要双工,但由于服务器端合同的某些部分需要双工,因此像 WSHttpBinding 这样的标准单工绑定将不起作用。

由于奇怪的 Silverlight WCF 要求(例如,将 HTTP 500 错误响应重写为 HTTP 200 等),我正在通过自定义 ServiceFactory 类初始化我的服务,其关键部分如下所示:

    protected override void InitializeRuntime()
    {

        // Add the WSDualHttpBinding.
        // This should listen at http://<servername>/RoomService.svc/wsdual
        WSDualHttpBinding wsDualBinding = new WSDualHttpBinding(WSDualHttpSecurityMode.None)
        {
            MessageEncoding = WSMessageEncoding.Text,
            TextEncoding = new System.Text.UTF8Encoding()
        };
        this.AddServiceEndpoint(
            typeof(IRoomService),
            wsDualBinding,
            "wsdual");

        // Add the PollingDuplexBinding
        // This should listen at http://<servername>/RoomService.svc
        PollingDuplexBindingElement pollingDuplexBindingElement = new PollingDuplexBindingElement()
        {
            // I'm not sure that these values are the best.  They're an initial guess.
            ServerPollTimeout = TimeSpan.FromSeconds(90),
            InactivityTimeout = TimeSpan.FromMinutes(30)
        };

        CustomBinding pollingDuplexBinding = new CustomBinding(
                            pollingDuplexBindingElement,
                            new BinaryMessageEncodingBindingElement(),
                            new HttpTransportBindingElement());

        this.AddServiceEndpoint(
            typeof(IRoomService),
            pollingDuplexBinding,
            "").Behaviors.Add(new SilverlightFaultBehavior());

        // Add the MetaData Exchange binding.
        this.AddServiceEndpoint(
            typeof(IMetadataExchange),
            MetadataExchangeBindings.CreateMexHttpBinding(),
            "mex");

        base.InitializeRuntime();
    }

而且(有点令人惊讶)一切正常。 Silverlight/PollingDuplex 客户端都获得了整洁的回调(比 SL 2.0 好得多!),并且 .NET/WSDualHttp 客户端都可以与服务器正常通信。

除了一件事。当我尝试调试应用程序时,Visual Studio 在通过 WSDualHttp 进行第一次单工调用时会抛出以下对话框:

“无法自动调试 'MyCompany.Service'。无法调试远程过程。这通常表示 Web 服务器上尚未启用调试。有关详细信息,请参阅帮助。”

错误消息相当不准确。事实证明,您可以通过任何 duplex(单向)调用对 Web 服务进行逐步调试,但不能通过任何 simplex(双向)调用.

现在,当然,我已经检查并确认我的 web.config 设置正确,即其中包含以下行:

<compilation debug="true">

我已经为此苦苦挣扎了很长时间,以至于我整理了一个相当简单的重现(可用here)来证明这个问题。据我所知,当您在 IIS 中使用 WSDualHttpBinding,然后尝试对该服务进行标准单工调用时,它就会出现。

我最初的解决方法是将 Duplex 从服务的 Simplex 部分中分离出来,此时一切正常 - 但以客户端上的重复对象模型为代价,这不是 理想。所以我把所有东西都移回了一个服务,但不能调试任何东西肯定是一件痛苦的事。

有没有其他人遇到过这个问题,或者有什么建议?

FWIW,我在MSDN 上或多或少地发布了同样的问题,但没有任何建议,并且我尝试使用 MS Connect 打开一个错误,但同样,该季度还没有任何帮助。

有什么想法吗?

【问题讨论】:

  • 不管怎样,我最终放弃在 IIS (6) 上使用 WSDualHttpBinding,并转而在自托管服务上使用 NetTCP。在那里调试没问题。

标签: debugging wcf-binding duplex


【解决方案1】:

事实证明这是一个真正的错误。它应该在 VS 2010 Beta 2 中修复。

请看这里:https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=472536&wa=wsignin1.0

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-12-08
    • 2011-11-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-10
    • 1970-01-01
    相关资源
    最近更新 更多