Trace Switch Issue

  • Thread starter Thread starter Donald Xie
  • Start date Start date
D

Donald Xie

Hi,

I'm having a strange problem with the BooleanSwitch loaded
from a config file.

<!-- The config file -->
<configuration>
<system.diagnostics>
<switches>
<add name="switchOn" value="1" />
</switches>
<trace autoflush="false" indentsize="4">
<add name="TextListener"

type="System.Diagnostics.TextWriterTraceListener, System"
initializeData="trace.log" />
</trace>
</system.diagnostics>
</configuration>

// The code
BooleanSwitch s = new BooleanSwitch("switchOn", "bla");
Console.WriteLine(s.Enabled);

s.Enabled is always false, regardless the value in config
file. If I remove the trace element from the config file,
s.Enabled is initialized correctly according to its value.

I've tried the different permutations of full type name
for the TextWriterTraceListener:

type="System.Diagnostics.TextWriterTraceListener, System,
version=1.0.5000.0, culture=neuture,
PublicKeyToken=b77a5c561934e089"

But the result is always the same. I'm using VS.NET 2003
with .NET Framework 1.1 on Windows XP. Does anyone have
the same problem? Any solutions?

Thanks,
Donald Xie
 
As soon as I posted it, I realized that I missed the
listeners tags. Sorry.

Donald Xie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top