C# Windows Service is locking file

J

JM

I have created a Windows Service which uses xml file as a data source.
The service is running on .NET 2.0 and uses LocalSystem account.

It was running fine but now it has started locking the xml file
sometimes. When I stop the service it unlocks the file.The service is
running all time. And it locks xml file sometimes not always.

I would really appreciate if anybody can guide me here.

Thanks
JM
 
G

Guest

Seems that class that works with fike is not disposed correctly.
Do u use using approach when work with your XML?

What's the version u run - debug or server?

--
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
J

JM

Hi Michael,

Thanks for the quick response.

I am using "ds.ReadXml(FileName)" for reading xml file and then using
"ds.WriteXml(FileName)" for writing XML from dataset. Where ds =
dataset and FileName = name of xml file.

I am compiling Windows Service in "debug" mode only and running that
version only. Whats the "server" mode? Is it the same as "release"
mode?

I have created windows service using VS 2005 in C# using .NET Framework
2.0.

Is there any better way of reading and writing XML. Dataset is
disconnected so there should not be any problem (I may be wrong).

Any help would be appreciated.

Regards
JM
 
G

Guest

Try to rebuild you app in "release" mode (I mistyped with "Server" mode)
In debug CLR can prolong object GC to the end of code block, not scope, thus
your file can be open when you are trying to write into in.

--
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
J

JM

Thanks for your help. I will test the app build in Release mode. I will
keep you posted about the results.

Thanks
JM
 
J

JM

I tried running windows service app in Release mode also. But its still
locking the file.

JM
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top