App.config, class library and tracing

  • Thread starter Thread starter Andrew
  • Start date Start date
A

Andrew

I have a class library that has app.config that has <system.diagnostics>
that specifies trace listeners. The class library is loaded by a third party
unmanaged application. I want the .NET framework to read the diagnostic
section and create listeners for me. For a managed executable, this is done
automatically, but not for a class library. What's the easiest way to have
..NET read and create the listeners, without me having to manually parse the
section and create listeners with new()?

Thanks
 
No, the problem is with managed code only.

Lets say I have c# exe that calls a method in c# class library (dll). In
app.config for both exe and dll I add <system.diagnostics>, <sources>,
<listeners> etc. (trace source names are different for exe and dll), then
call TraceEvent from exe and dll. Exe produces trace output, dll does not.
That's apparently because the framework does not process
<system.diagnostics> for a class library. I want an easy way to create
listeners for dll based on the info in app.config.
 
Back
Top