调试WCF中的命名管道

时间:2009-08-20 23:37:05

标签: wcf wcf-binding

由于开发服务器不支持使用除HTTP(http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/c7f173ea-61dc-4338-8883-60d616adc18f/)之外的任何绑定,那么如何调试NetNamedPipeBinding?

现在,当我使用Microsoft服务配置编辑器将绑定类型从basicHttpBinding更改为netNamedPipeBinding时,当我尝试按F5以使用弹出的自动生成的WCF工具时,我收到以下错误消息。

  

System.InvalidOperationException:找不到与绑定NetNamedPipeBinding的端点匹配scheme net.pipe的基址。注册的基地址方案是[http]。      在System.ServiceModel.ServiceHostBase.MakeAbsoluteUri(Uri relativeOrAbsoluteUri,Binding binding,UriSchemeKeyedCollection baseAddresses)      在System.ServiceModel.Description.ConfigLoader.LoadServiceDescription(ServiceHostBase主机,ServiceDescription描述,ServiceElement serviceElement,Action`1 addBaseAddress)      在System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader,ServiceDescription description,ServiceElement serviceSection)      在System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader,ServiceDescription description,String configurationName)      在System.ServiceModel.ServiceHostBase.ApplyConfiguration()      在System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses)      在System.ServiceModel.ServiceHost.InitializeDescription(类型serviceType,UriSchemeKeyedCollection baseAddresses)      在System.ServiceModel.ServiceHost..ctor(类型serviceType,Uri [] baseAddresses)      在Microsoft.Tools.SvcHost.ServiceHostHelper.CreateServiceHost(Type type,ServiceKind kind)      在Microsoft.Tools.SvcHost.ServiceHostHelper.OpenService(ServiceInfo info)

配置:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
  </configSections>
  <system.web>
    <compilation debug="true" />
  </system.web>
  <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
    <bindings>
      <netNamedPipeBinding>
        <binding name="NewBinding0" />
      </netNamedPipeBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="InventoryServiceLibrary.Service1Behavior"
        name="InventoryServiceLibrary.InventoryService">
        <endpoint address="" binding="netNamedPipeBinding" bindingConfiguration=""
          contract="InventoryServiceLibrary.IInventoryService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
          contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8731/Design_Time_Addresses/InventoryServiceLibrary/Service1/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="InventoryServiceLibrary.Service1Behavior">
          <!-- To avoid disclosing metadata information, 
          set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="True"/>
          <!-- To receive exception details in faults for debugging purposes, 
          set the value below to true.  Set to false before deployment 
          to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

解决方案 创建命名管道绑定后添加基址

3 个答案:

答案 0 :(得分:3)

告诉我们您的配置!!无论是客户端还是服务器。

消息“无法找到与绑定NetNamedPipeBinding的端点匹配scheme net.pipe的基址”。基本上都说了 - 看起来好像你的服务器配置包含任何使用net.pipe绑定的端点或基地址:

<services>
   <service name="xxxx">
       <host>
           <baseAddresses>
               <add baseAddress="http://localhost:8000/MyService" />
               <add baseAddress="net.tcp://localhost:8100/MyService" />
               <add baseAddress="net.pipe://localhost/" />

您还需要在服务器的配置中指定至少一个net.pipe端点才能使用此协议。

正如其他人也评论过的那样,WCF只允许net.pipe绑定本地机器调用,例如:你无法从一台物理机器呼叫到另一台物理机器。如果您需要该功能,请改用net.tcp绑定。

马克

答案 1 :(得分:1)

您可以随时使用Attach To Process而不是直接从调试器启动并将其附加到主机进程。

答案 2 :(得分:0)

这些答案具有误导性。如果您是自托管WCF服务,则需要“基本地址”部分。但是,如果您使用IIS托管,则不需要也不使用它。