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.
e.g.
  <%@ 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.

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

  namespace Foo.Bar
 {
...


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

BUT WHERE'S MY DEBUGGING?

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">
      <listeners>
        <add name="LogFileListener" type="Foo.Bar.TextWriterTraceListener, Foo.Bar.Diagnostics" initializeData="FooBarLog-{0:yyyy-MM-dd}.txt" />
      </listeners>
    </trace>
...

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

[LATER]

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"?>
<configuration>
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp"
                extension=".cs"
                warningLevel="4"
                compilerOptions="/d:TRACE
type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
        <providerOption name="CompilerVersion" value="v3.5" />
        <providerOption name="WarnAsError" value="false" />
      </compiler>

No comments: