【问题标题】:Minimum configuration to make "Add Service Reference > Discover" work使“添加服务参考 > 发现”工作的最低配置
【发布时间】:2012-01-23 08:42:17
【问题描述】:

我已经对一些 WCF + Windows 服务进行了测试,并且在远程开发机器上作为 Windows 服务运行时可以正常工作。除了一个。

为了调试,我尝试使用内置的“添加服务引用”托管 WCF(没有 Windows 服务),然后在 Visual Studio 中托管它(不知道主机叫什么)。

无论如何,我无法获得 Add Service Reference 以发现我的服务。

因为我使用的是 Windoes 服务,所以我使用的是 TCP 的东西。这是我所做的一些事情,都在我正在添加服务引用的 winforms 应用程序中

添加项目 > 属性 > 调试 > 命令行参数:/client:"WcfTestClient.exe" 但 exe 不运行。

还有我的 App.Config

<?xml version="1.0"?>
<configuration>
  <system.serviceModel>
    <client>
      <endpoint address="net.tcp://localhost:32279/SYNC" binding="netTcpBinding"
        bindingConfiguration="tcpSyncBindingConfig" contract="Company.Data.Sync.ILocalCacheSyncContract"
        name="tcpSyncClientEP" />
    </client>
    <bindings>
      <netTcpBinding>
        <binding name="tcpSyncBindingConfig" maxReceivedMessageSize="6553600" />
      </netTcpBinding>
      <mexTcpBinding>
        <binding name="tcpMexBindingConfig" />
      </mexTcpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="svcBehavior" name="Company.Data.Sync.Services.LocalCacheSyncService">
        <endpoint address="net.tcp://localhost:32279/Sync" binding="netTcpBinding"
          bindingConfiguration="tcpSyncBindingConfig" name="tcpSyncListenEP"
          contract="Company.Data.Sync.Services.ILocalCacheSyncContract" />
        <endpoint address="net.tcp://localhost:32279/Sync/mex" binding="mexTcpBinding"
          bindingConfiguration="tcpMexBindingConfig" name="tcpMexEP" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="svcBehavior">
          <serviceMetadata httpGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

旁注:ServiceOperation 正在返回 Microsoft.Synchronization.Data.xxx sutff,例如 SyncContext。我可能需要在 Winforms 中添加引用?或者“添加服务参考”会为我添加它们吗?服务和合约由本地数据库缓存模板生成。可能与问题无关。

【问题讨论】:

    标签: c# wcf visual-studio-2010


    【解决方案1】:

    发布后,我继续寻找答案,这就是我尝试的工作:

    项目文件本身,例如*.csproj for C# 项目必须包含 ProjectTypeGuid for WCF for Visual Studio 才能开始检查项目的服务。

    <ProjectTypeGuids>{3D9AD99F-2412-4246-B90B-4EAA41C64699};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    

    更多 GUID 可以在 http://www.mztools.com/articles/2008/mz2008017.aspx 找到。 (感谢 mztools!)

    WCF 项目可以有多个服务,每个服务都需要在项目的 App.Config 中定义其配置。每个服务都需要有一个不同的 mex 端点地址。这些服务还可以共享一个定义了 serviceMetadata 扩展的服务行为。 Mex 端点不需要行为或绑定配置。但请记住将 mex 端点合约设置为 IMetadataExhchange。

    对于 TCP mex,serviceMetadata > HttpGetEnabled 必须设置为 false。

    我相信这是最低设置。

    【讨论】:

      【解决方案2】:

      右键单击您希望在 PC 上托管的服务,然后右键单击并转到“调试”>“启动新实例”

      然后转到您的其他应用程序(我假设相同的解决方案)并复制它正在运行的 URL。

      然后您可以使用上述相同的方法启动该项目,并在本地计算机上调试两个项目。

      我认为这就是你想要做的。如果是其他原因,请告诉我。

      【讨论】:

      • 此方法仅适用于我拥有的 4 个 dll 中的 1 个。对dll有什么要求吗?例如,dll中只能有一个Service?它给出了“无法启动类库的输出类型......”
      • 他说Anyways, I cannot get the Add Service Reference to Discover my services
      • @jgauffin 实际上我认为让其中一个或另一个工作将使两者都工作。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-07
      • 1970-01-01
      • 2013-04-13
      • 2015-05-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多