开发者

Cannot debug wcf-windows service

开发者 https://www.devze.com 2023-01-24 11:58 出处:网络
Our application accesses a WCF service, which is hosted by a Windows Service on a single computer.The client application and service always will be on the same computer.

Our application accesses a WCF service, which is hosted by a Windows Service on a single computer. The client application and service always will be on the same computer.

I've created a Windows Service that hosts a WCF service. To test my Windows Service code, I created a console application that contains the same app.config and code as my Windows Service. I start the console application in one debugging thread, and launch my client in another debugging thread. Everything works perfectly and I can easily use the debugger.

Now the rub...

So, I created an installer and installed my Windows Service. After successfully starting it, I successfully added the Service Reference to my client using http://localhost/VssService within Visual Studio 2010. I successfully attached to the service via "Attach To Process". I launched my client in a debugging thread, but when I try to step into a remote method, I get "Unable to automatically step into the server. The debugger failed to stop in the server process." This happens for both [NetNamedPipeBinding_IVssService] and [BasicHttpBinding_IVssService]. I have been struggling with this for hours and have run out of ideas, so I hope that you can help me. I've included the app.config files for my Windows Service and Client application. Hopefully they will help.

I appreciate your taking time to read this question and hope that you can help be to resolve this problem...

Mike

===================== SERVICE APP.CONFIG =============================

    <services>
    开发者_JAVA技巧    <service behaviorConfiguration="VssServiceBehavior" name="ClientSaver.VssService.VssService">
            <endpoint address="net.pipe://localhost/VssService/Pipe/" binding="netNamedPipeBinding"
                bindingConfiguration="" contract="ClientSaver.VssService.IVssService" />
            <endpoint address="http://localhost/VssService/" binding="basicHttpBinding"
                bindingConfiguration="" contract="ClientSaver.VssService.IVssService" />
            <endpoint address="http://localhost/VssService/MEX/" binding="mexHttpBinding"
                bindingConfiguration="" contract="IMetadataExchange" />
            <host>
                <baseAddresses>
                    <add baseAddress="http://localhost/VssService/" />
                </baseAddresses>
            </host>
        </service>
    </services>

  <behaviors>
    <serviceBehaviors>
      <behavior name="VssServiceBehavior">
        <serviceMetadata httpGetEnabled="True" policyVersion="Policy15" />
        <serviceDebug includeExceptionDetailInFaults="False" />
      </behavior>
    </serviceBehaviors>
  </behaviors>      
</system.serviceModel>

========================= CLIENT APP.CONFIG =============================

            <endpoint address="http://localhost/VssService/" binding="basicHttpBinding"
                bindingConfiguration="" contract="ClientSaver.VssService.IVssService" />                            
        </service>
    </services>

  <behaviors>
    <serviceBehaviors>
      <behavior name="VssServiceBehavior">
        <serviceMetadata httpGetEnabled="true" policyVersion="Policy15" />
        <serviceDebug includeExceptionDetailInFaults="true" />
      </behavior>
    </serviceBehaviors>
  </behaviors>      
</system.serviceModel>


Ok. One way I use when VS debugging stops working is to place a System.Diagnostics.Debugger.Break() in a conventient place in the service code (say, constructor or method). This causes the JIT debugger to fire up and allows me to connect to the service with the code broken at that point with any VS instance I have.

Obviously you remove it from non debugging code.


You can't step across executable boundaries. Youll need to set breakpoint in your server code (that is project). Then from server`s project attach to the running windows service process (be carefull here ... you need to have latest server project running as windows service). Then, when you step in your Windows Forms app, it'll get caught by the server's breakpoint.


You should use internet explorer as default browser to debug your service...


Have a look at the debugging tools for windows. There are a couple of tools in here that are useful for debugging windows services.


Have you tried manually loading debug symbols? It once happened to me and it was happening because VS was not loading the symbols.

0

精彩评论

暂无评论...
验证码 换一张
取 消