Tuesday, 24 June 2014

Where's my .asmx debugging gone?

I wanted to simplify the deployment of a web service and provide the client with the source so that we could do some fault analysis.

I'd already supplied a .asmx with (some of) the code behind.
  <%@ WebService Language="C#" Class="Foo.Bar.DoStuff" %>

with the class Foo.Bar.DoStuff in a Foo.Bar assembly xcopy's to the web service's 'bin' folder.

All well and good...

I started moving the code to be inline within the .asmx.

  <%@ WebService Language="C#" Class="Foo.Bar.DoStuff2" %>

  namespace Foo.Bar

  public class DoStuff2 : DoStuff
    static DoStuff2 ()
      Trace.WriteLine("Using the replacement web service!");


My original trace listener's still in the web.config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration> <system.diagnostics>
    <trace autoflush="true" indentsize="4">
        <add name="LogFileListener" type="Foo.Bar.TextWriterTraceListener, Foo.Bar.Diagnostics" initializeData="FooBarLog-{0:yyyy-MM-dd}.txt" />

But only the Trace output from the assembly's being emitted.


The code's now being compiled automajically by IIS so we need to tell IIS to include the TRACE switch in the compiler options:

<?xml version="1.0" encoding="UTF-8"?>
      <compiler language="c#;cs;csharp"
type="Microsoft.CSharp.CSharpCodeProvider, System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089">
        <providerOption name="CompilerVersion" value="v3.5" />
        <providerOption name="WarnAsError" value="false" />