0

我的项目基于 WCF Web 服务,在调试时,它正在启动 WCF 测试客户端。当我遇到错误时,而不是在特定点中断代码,它只是将错误报告回 WCF 测试客户端。

我希望它能够中断代码,这样我就可以调试并观察它正在中断哪些记录。这曾经发生过,但突然停止工作。我不知道这是否是我在 web.config 中禁用的东西。

Project Web Server 仍设置为 IIS Express (localhost:#####),而且我还有其他项目使用 WCF 测试客户端,它们在代码中的中断就好了。

<?xml version="1.0"?>
<configuration>

  <configSections>
    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
      <section name="ConnectorService.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </sectionGroup>
  </configSections>
  <appSettings>
     <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime requestValidationMode="2.0" targetFramework="4.5"/>
  </system.web>
  <system.serviceModel>
    <behaviors>

      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>

    </behaviors> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <directoryBrowse enabled="true"/>
  </system.webServer>

  <applicationSettings>
    <ConnectorService.Properties.Settings>
      <setting name="ConnectionName" serializeAs="String">
        <value>Test</value>
      </setting>
      <setting name="UserName" serializeAs="String">
        <value>TestUser</value>
      </setting>
      <setting name="Password" serializeAs="String">
        <value>Password</value>
      </setting>
    </ConnectorService.Properties.Settings>
  </applicationSettings>
</configuration>

我不知道它可能是什么,如果我能提供更多信息,请问,谢谢。

4

3 回答 3

0

出色地!如果您正在制作REST服务,那么Fidler是一个不错的选择。

  1. 始终使用日志记录机制。就像引发异常一样,创建一个文件并将日志详细信息放在该文件中的catch块中。

  2. 要进行调试,一个选项是附加到Visual Studio 中的进程选项。在菜单栏中,转到Debug,然后Attach to process...并选择适当的进程(可能是 Fiddler)。

  3. 另一种选择是,在同一个 WCF 解决方案中创建另一个项目(客户端项目)。确保您的客户端项目使用您的 WCF 服务。现在右键单击您的解决方案,单击Set StartUp Project...,选中 Radio Button Multiple startup projects...,然后从您的项目列表中选择Action to Start

  4. 之后,在要调试的 WCF 代码中使用断点运行项目,然后执行客户端。当发出请求时,它将到达断点。确保您在调试模式下运行。

看到这个答案

于 2014-02-13T13:43:25.213 回答
0

确保在启动客户端时将其附加到调试器。以下 是如何将进程附加到调试器。

于 2014-02-13T13:53:01.300 回答
0

我意识到这是一个非常古老的问题,但我相信这是由 web.config 中的此设置引起的:aspNetCompatibilityEnabled="true"

于 2019-08-22T16:32:48.307 回答