By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,871 Members | 2,304 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,871 IT Pros & Developers. It's quick & easy.

Help needed on Trace operation

P: n/a
============ RESEND ================

Dear all,

I have implementing some tracing function in my
applicatrion to store log information to file and event
logger.

I have actually a problem to logging to file, hwhere I get
an exception error saying :

"Cannot access to file becasue it is use by an other
process"

The error comes the second time I try to write to the file.

I have try to close the file and the trace stuff after
each write but nothing much still the error.

I have implemented as follow :

m_LogFile = New FileStream(m_File, FileMode.OpenOrCreate,
FileAccess.ReadWrite)
m_Listner = New TextWriterTraceListener
(m_LogFile)

'-- handle objet for sending to EvLog
m_EventLog = New EventLog("Debug Log")
m_EvtListner = New EventLogTraceListener
(m_EventLog)
m_EventLog.Source =
Source.GetType.Namespace.ToString

Trace.Listeners.Add(m_Listner)
Trace.Listeners.Add(m_EvtListner)
Trace.AutoFlush = True

The exception comes when the m_LogFile object start to
initialised.
IMPORTANT :
=============
The code above is located in a separate assembly that the
call which is instanciate the object for writing to log.

If I paste this code in the same assembly that the
instance is created it works fine all time
Any help will be aprreciate
Jul 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.