调试WCF时无法自动进入服务器

Mat*_*att 9 .net debugging wcf

我害怕:

无法自动进入服务器.无法调试远程过程.这通常表示尚未在服务器上启用调试."

现在,我一直在阅读我需要添加的内容

<compilation debug="true">
Run Code Online (Sandbox Code Playgroud)

到web.config.

很公平,我的问题是我的WCF服务是一个在windows进程中托管的nettcp绑定.

我在哪里添加这个?在Windows服务的app.config中,WCF服务是什么?

在哪一节?现在我的Windows服务主机的app.config如下所示:

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

  <system.serviceModel>
    <services>
      <service name="Indexer" behaviorConfiguration="IndexerServiceBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8000/Indexer"/>
          </baseAddresses>
        </host>
        <endpoint address="net.tcp://localhost:9000/Indexer"
                  binding="netTcpBinding"
                  bindingConfiguration="Binding1"
                  contract="WCF.IIndexer" />
      </service>
    </services>
    <bindings>
      <netTcpBinding>
        <binding name="Binding1"
                     hostNameComparisonMode="StrongWildcard"
                     sendTimeout="00:10:00"
                     maxReceivedMessageSize="65536"
                     transferMode="Buffered"
                     portSharingEnabled="false">
          <security mode="None">
            <transport clientCredentialType="None" />
            <message clientCredentialType="None" />
          </security>
        </binding>
      </netTcpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="IndexerServiceBehavior">
          <serviceMetadata httpGetEnabled="true" httpGetUrl=""/>
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>

  </system.serviceModel>

</configuration>
Run Code Online (Sandbox Code Playgroud)

小智 14

首先,我在Visual Studio 2015中遇到此问题.

如果在调用WCF服务的行上添加断点并在调试时按F11进入WCF代码,请注意必须在要调用的WCF服务的第一行添加断点.


dan*_*ann 9

我刚遇到同样的问题.为了能够调试WCF服务,您应该<compilation debug="true">在该<system.web>部分内的服务器配置文件中添加该行.

有关详细信息,请查看链接:http: //msdn.microsoft.com/en-us/library/bb157687.aspx

  • "在部分内添加服务器的配置文件." - 我还不太清楚该怎么做.你在这里写的是什么意思? (9认同)

小智 5

<pre>
Add the below in your server config file
(i) Add below in app.config, if you are hosting your WCF service on windows service. 
<system.web>
  ...
  ...
  ...
  <compilation debug="true" /> 
</system.web>

(ii) Add below in web.config, if you are hosting your WCF service on IIS. 
<system.web>
  ...
  ...
  ...
  <compilation debug="true" /> 
</system.web>
</pre>
Run Code Online (Sandbox Code Playgroud)