1
Vote

TraceListeners could use a more useful error message when initializeData is missing

description

I spent a good deal of time tracking down why a listener was throwing a configuration exception
Ref: http://stackoverflow.com/questions/8595845/im-getting-an-configurationerrorsexception-couldnt-find-constructor-for-class
 
It occured to me that if there was an override of the parameterless constructor, that a useful error message could be thrown. I added the following code and check, that this still throws a configuration exception, but now the inner exception lets the user know what is missing.
 
public class DebuggerTraceListener : CustomTraceListener
{
    public DebuggerTraceListener()
    {
        throw new InvalidOperationException("intializeData section must be blank. It needs top be filled in.");
    }

comments