0

我有一个基于 Unity 的 C# WPF 应用程序,它有一个与同一解决方案中基于 WCF 的项目通信的模块。

如果我使用 WCF 测试主机使其成为活动服务,则 WCF dll 可以工作,但如果我尝试从代码创建 ServiceHost,则会超时。

这是 Unity Modules Initialization() 中的代码

host = new ServiceHost(typeof(AtomCfgModelClient));
host.Open();

这是我的 app.config 部分

  <endpoint address="http://localhost:8080/AtomCfgModelService"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IAtomCfgModel"
contract="AtomCfgModel.IAtomCfgModel" name="WSHttpBinding_IAtomCfgModel">
    <identity>
      <dns value="localhost" />
    </identity>
  </endpoint>
</client>

<services>
  <service name="AtomCfgModule.AtomCfgModel.AtomCfgModelClient" >
    <endpoint   address="" binding="wsHttpBinding" contract="AtomCfgModel.IAtomCfgModel"    >
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint name="mex" address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8080/AtomCfgModelService" />
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior >
      <serviceMetadata httpGetEnabled="True" />
      <serviceDebug includeExceptionDetailInFaults="False" />
    </behavior>
  </serviceBehaviors>
</behaviors>

我从 wcf 项目属性设置中关闭了“调试时启动 WCF 服务主机”。

所以,上面的配置似乎可以从 wcf 跟踪文件加载,但是当我去使用任何服务时,我得到一个超时,没有任何我可以看到的信息让我知道是什么导致了超时。

这是来自 wcf 跟踪的错误消息,在此异常消息之前,所有消息似乎都成功了。对“http://localhost:8080/AtomCfgModelService”的 HTTP 请求已超过分配的超时 00:00:59.9840000。分配给此操作的时间可能是较长超时的一部分。

令人困惑的是,如果我使用 WCF 测试主机,则上述配置有效

                            String arg = "/service:\"" + Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AtomCfgModel.dll") + "\" /config:\"" + Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "GISShell.exe.config") + "\"";
                            System.Diagnostics.Process.Start(@"c:\WcfSvcHost.exe", arg);

上面运行 wcfsvchost.exe 的代码使用相同的配置(和 WCF dll),我没有得到超时。

有关如何调试/修复此问题的任何要点都会很棒。

4

0 回答 0