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

C# Windows Service is locking file

P: n/a
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

Sep 28 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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

"JM" wrote:
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

Sep 28 '06 #2

P: n/a
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

Michael Nemtsev wrote:
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

"JM" wrote:
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
Sep 29 '06 #3

P: n/a
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


"JM" wrote:
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

Michael Nemtsev wrote:
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

"JM" wrote:
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
>
>

Sep 29 '06 #4

P: n/a
JM
Thanks for your help. I will test the app build in Release mode. I will
keep you posted about the results.

Thanks
JM

Michael Nemtsev wrote:
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


"JM" wrote:
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

Michael Nemtsev wrote:
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
>
"JM" wrote:
>
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
Sep 29 '06 #5

P: n/a
JM
I tried running windows service app in Release mode also. But its still
locking the file.

JM

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

Thanks
JM

Michael Nemtsev wrote:
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


"JM" wrote:
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
>
Michael Nemtsev wrote:
>
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

"JM" wrote:

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
>
>
>
>
Sep 30 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.