Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Trace listeners

Reply
Thread Tools

Trace listeners

 
 
martin
Guest
Posts: n/a
 
      12-17-2003
Hi,

I have created an asp.net application as a project, and also another project
that is just a class library.
My asp.net application calls a function in the class library.
I am attempting to place instrumentation inside the function of my class
library to write to a text file, I am using an TextWriterTraceListener
object..

The problem is that I can write to the trace listener with the following
code, but only once

' Creates the text file that the trace listener will write to.
Dim myTraceLog As New System.IO.FileStream("C:\myTraceLog.txt",
IO.FileMode.Append)
' Creates the new trace listener
Dim myListener As New TextWriterTraceListener(myTraceLog)
Trace.Listeners.Add(myListener)
myListener.WriteLine("Called IsSecureUser Function")
Trace.Flush()
myListener.Flush()

The class function (above) is called from a button click event. The first
time the button is pressed then no problem.
If the button is clicked again then I get an error saying "The process
cannot access the file "C:\myTraceLog.txt" because it is being used by
another process."

if I close the file at the end of the function I get the error "Cannot
access a closed file."

and if I close the trace listener I get "Cannot write to a closed
TextWriter." the first time that I press the button.

could anybody please tell me how I re use the trace listener over and over
again without the error.

thank you in advance.

cheers

martin.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find all event listeners on a link, including delegated listeners? Matt Kruse Javascript 2 05-28-2010 06:28 AM
Initializing custom trace listeners in web.config boldtbanan@gmail.com ASP .Net 0 04-05-2007 04:35 PM
<system.diagnostics> causing a Configuration Error while setting Trace Listeners. msnews.microsoft.com ASP .Net 0 01-05-2007 07:50 PM
Trace Listeners in a web app Martin ASP .Net 1 05-31-2004 06:19 PM
Trace: Can anyone suggest a good tool to catch trace messages? Rukmal Fernando ASP .Net 4 10-27-2003 09:03 PM



Advertisments