Cannot select CustomTraceListener with "Type Selector" window

Topics: Logging Application Block
Apr 1, 2010 at 12:02 PM

i created a Custom Trace Liastener inside a class library :

namespace SendMailTraceListener
{
    [ConfigurationElementType(typeof(CustomTraceListenerData))]
    public class SendEmailTraceListener : CustomTraceListener
    {


        public override void Write(string message)
        {

            throw new NotImplementedException();
        }

        public override void WriteLine(string message)
        {
            throw new NotImplementedException();
        }


    }
}

it compiles fine.

Then i created new TraceListener and pushed the "Type" button in the properties to open the "Type selector" window.

i pushed "Load from file" button and browsed to the Custom Trace Listener class library and chose the dll from the Bin->Debug folder of the class library.

but it doesn't work, i get the message:

"There were no types found in the assembly 'SendMailTraceListener' that implement or inherit from the base type 'Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.CustomTraceListener'."

Why ? !!!

Apr 1, 2010 at 7:02 PM

Got it!

It is a Visual Studio 2008 bug.

when i used the Enterprise Library Configuration application itself ( not the VS2008  -"Edit Enterprise Library Configuration" ) , it works!

Apr 5, 2010 at 5:56 AM

Once an assembly has been loaded into the visual studio environment, it doesn't load a new version of it.  So if you've previously loaded that assembly prior to creating your custom trace listener and building it, it uses that version and thus, can't find your custom trace listener.   I'm not sure if it's a bug in Visual Studio or considered as an expected behavior.

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com