Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / September 2006

Tip: Looking for answers? Try searching our database.

C# Windows Service is locking file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JM - 28 Sep 2006 09:36 GMT
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
Michael Nemtsev - 28 Sep 2006 10:22 GMT
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?

Signature

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

> 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.
[quoted text clipped - 7 lines]
> Thanks
> JM
JM - 29 Sep 2006 09:55 GMT
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

> Seems that class that works with fike is not disposed correctly.
> Do u use using approach when work with your XML?
[quoted text clipped - 19 lines]
> > Thanks
> > JM
Michael Nemtsev - 29 Sep 2006 10:59 GMT
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.

Signature

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

> Hi Michael,
>
[quoted text clipped - 42 lines]
> > > Thanks
> > > JM
JM - 29 Sep 2006 11:15 GMT
Thanks for your help. I will test the app build in Release mode. I will
keep you posted about the results.

Thanks
JM

> 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
[quoted text clipped - 53 lines]
> > > > Thanks
> > > > JM
JM - 30 Sep 2006 06:54 GMT
I tried running windows service app in Release mode also. But its still
locking the file.

JM

> Thanks for your help. I will test the app build in Release mode. I will
> keep you posted about the results.
[quoted text clipped - 59 lines]
> > > > > Thanks
> > > > > JM

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.