473,386 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Trace listeners

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.
Nov 18 '05 #1
0 1199

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Geopsaros | last post by:
Hi! I have created a custom trace Listener class, called "DBTraceListener" it works fine when i add it manually in code : (eg. Trace.listeners.add(new DBTraceListener("myDBListener",...
2
by: Wilfried Hoermann | last post by:
Presumably a trivial question... I want to write trace information from a web service to a log file using the Trace Class. Is this possible without closing and opening the Trace in every single...
1
by: pokémon | last post by:
Ok, I am baffled by this one: I have 2 custom trace listeners (classes that inherit from System.Diagnostics.TraceListener). I want them both to listen to the same Windows application. How...
1
by: Martin | last post by:
Hi, is it a wise thing to do to place trace listeners (that write to a text file) into an asp.net application. I wish to do this for testing so that a user may vist as many different pages as...
1
by: Patrick | last post by:
When Tracing in ASP.NET, the IIS process (on IIs5.1) is locking on the Trace file, and I can't read the trace file without restarting the IIS: Even the following does NOT work (how could I fix...
0
by: msnews.microsoft.com | last post by:
Hi, I am tring to use Trace Listener in asp.net 1.1 application as mentoned here. But i am getting the following error, Configuration Error Description: An error occurred during the processing...
0
by: shilpa8120002000 | last post by:
Hi I have a doubt.I know what is a trace listener , What are the uses of trace listener and different types of trace listeners. I created a TextWriterListener.But when I run that...
6
by: Zytan | last post by:
According to http://www.15seconds.com/issue/020910.htm I am doing this in the c'tor of a 'logfile' class: objStream = new System.IO.FileStream(logFilename, System.IO.FileMode.OpenOrCreate);...
0
by: boldtbanan | last post by:
I've created a custom trace listener which I'd like to initialize in the web.config file of my application. I noticed that I can use the initializeData attribute to pass a string to the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.