M
michael sorens
I created a custom TraceListener by subclassing a TextWriterTraceListener.
(TextWriterTraceListener has most of what I want already.) My custom
TraceListener works fine when I instantiate it through code. When I attempt
to instantiate it in the app.config file, however, it is not able to find the
class. In the same config file I reference several other standard
TraceListeners that work just fine. Here is the relevant portion of the
app.config file:
<add name="MyListener"
type="TraceSourceGuiApp.MyTextWriterTraceListener"
initializeData="diagnostic.txt">
<filter type="System.Diagnostics.EventTypeFilter"
initializeData="Off"/>
</add>
The exact error is:
ConfigurationErrorsException - Couldn't find type class for
TraceSourceGuiApp.MyTextWriterTraceListener
The error manifests when I attempt to access a different listener in the
Listener collection.
Here is the alternate code version that works just fine:
MyTextWriterTraceListener l =
new MyTextWriterTraceListener("diagnostics.txt", "MyListener");
mySource.Listeners.Add(l);
I initially set this up so the custom listener class is in a separate DLL
but I also tried it within the same project and got the same result.
What is the appropriate way to access a custom listener from app.config?
[Env: .Net 2.0]
(TextWriterTraceListener has most of what I want already.) My custom
TraceListener works fine when I instantiate it through code. When I attempt
to instantiate it in the app.config file, however, it is not able to find the
class. In the same config file I reference several other standard
TraceListeners that work just fine. Here is the relevant portion of the
app.config file:
<add name="MyListener"
type="TraceSourceGuiApp.MyTextWriterTraceListener"
initializeData="diagnostic.txt">
<filter type="System.Diagnostics.EventTypeFilter"
initializeData="Off"/>
</add>
The exact error is:
ConfigurationErrorsException - Couldn't find type class for
TraceSourceGuiApp.MyTextWriterTraceListener
The error manifests when I attempt to access a different listener in the
Listener collection.
Here is the alternate code version that works just fine:
MyTextWriterTraceListener l =
new MyTextWriterTraceListener("diagnostics.txt", "MyListener");
mySource.Listeners.Add(l);
I initially set this up so the custom listener class is in a separate DLL
but I also tried it within the same project and got the same result.
What is the appropriate way to access a custom listener from app.config?
[Env: .Net 2.0]