Your Type string is likely invalid.

It's format is:

"Type Name, Assembly Name"

Assembly name format is:

"Assembly Name[, PublicKeyToken][,Culture][,Version][,et cetera]"

So unless your Type is called System.Diagnostics.TraceListener, you've
specified the wrong type name.

Adam..

-----Original Message-----
From: Discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] On Behalf Of Ben Joyce
Sent: Wednesday, August 23, 2006 10:31 AM
To: [email protected]
Subject: [ADVANCED-DOTNET] Creating a custom TraceListener...

Hi all.

I'm trying to write a TraceListener to log Debug.Write output into a
database.

I've made a simple class as follows:

----- 8<-----
Public Class CustomListener

Inherits System.Diagnostics.TraceListener

Public Overloads Overrides Sub Write(ByVal Message As String)

'yadda

End Sub

Public Overloads Overrides Sub WriteLine(ByVal Message As String)

'yadda

End Sub

End Class
----- >8 -----

And I have added the following to my web.config file:

----- 8< -----
        <system.diagnostics>
                <trace autoflush="true" indentsize="0">
                        <listeners>
                                <add name="MyCustomListener"
type="System.Diagnostics.TraceListener,CustomListener" />
                        </listeners>
                </trace>
        </system.diagnostics>
----- >8 -----

However, I'm getting an error when I try to do a Debug.Write:

----- 8< -----
An exception of type
'System.Configuration.ConfigurationErrorsException' occurred in
System.dll but was not handled in user code

Additional information: Couldn't find type for class
System.Diagnostics.TraceListener,CustomListener.
----- >8 -----

Anyone got any ideas?  Bit stumped here.

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to