Hi All,
I have created a web service in .net 2.0, C#. I need to log some information to a file whenever different methods are called by the web service clients.
The problem comes when one user process is writing to a file and another process tries to write to it. I get the error "The process cannot access the file because it is being used by another process".
The solutions that I have tried to implement in C# and failed are as below.
1) Implemented singleton class that contains code that writes to a file. 2) Used lock statement to wrap the code that writes to the file.
I have also tried to use open source logger log4net but it also is not a perfect solution. I know about logging to system event logger, but I do not have that choice.
I want to know if there exists a perfect and complete solution to such a problem?
I have posted this question once before on MSDN but didnt get a proper answer. Hope this time the nut is cracked :)
Thanks! pradeep_tp