Config tool is not loading the custom trace listeners

Topics: Building and extending application blocks
Aug 20, 2009 at 4:34 AM

Hi All,

I have created a custom database trace listener which will inherit from CustomTraceListener class. I have added all the required code and build the dll. It has build successfully. But when I try to select that assembly in the configuration tool, the type selector is showing the below error.

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

I have given the name space for my dll as "EntLib.Extended.LoggingTest.Logging". When I change the namespace from that one to "EntLibExtendedLoggingTestLogging", then the type selector is showing the correct class in the configuration console.

namespace EntLib.Extended.LoggingTest.Logging
{
    [ConfigurationElementType(typeof(CustomTraceListenerData))]
    public class ExtDBTraceListener : CustomTraceListener
    {
        public override void TraceData(TraceEventCache eventCache, string source, TraceEventType eventType, int id, object data)
        {
              // some code here
        }

        public override void Write(object o)
        {
            // code here
        }
    }
}

When I change the namespace in the above code to "EntLibExtendedLoggingTestLogging", then the config control is showing the correct class in the console.

What is the problem if I give the namespace like above with '.'? Could you please tell me how to resolve this error?

 

 

 

Aug 20, 2009 at 6:03 AM

Hi,

Sorry cant repro the error you've encountered. Was you class in a separate class lib? What is the assembly name and the DefaultNamespace of the class lib? I tried creating a class lib project with a name of "EntLibExtendedLoggingTestLogging", and I added the class  you posted with the name space of "EntLib.Extended.LoggingTest.Logging". I tried loading the custom trace listener and seems to be loading correctly. Maybe I missed some steps to repro, please provide more detail.

 

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Aug 20, 2009 at 6:09 AM

Hi Please try the following steps.

Create a class library project with name as "EntLib.Extended.LoggingTest.Logging".

Add a class which inherits from customtracelistener class to the above project. The class will get the default namespace as  "EntLib.Extended.LoggingTest.Logging".

Now build the project and try loading that dll. The dll name also will be "EntLib.Extended.LoggingTest.Logging.dll" 

Aug 20, 2009 at 6:33 AM

Hi,

I followed you step. Same result, it is still loaded correctly. What ent lib version are you using? Can you please try to remove the custom trace listener, then save. Close the visual studio, and open a new instance of VS then re-add the custom trace listener.

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com