Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


using xmlReader from a windows service and locking file until service is stopped!

Posted on 2005-04-11
Medium Priority
Last Modified: 2010-08-05
I have the following code in the windows service written in VB.NET:

Dim textReader As New XmlTextReader(path)
        Do While textReader.Read
            If textReader.NodeType = XmlNodeType.Element Then
                If textReader.Name = key Then
                    Return textReader.ReadElementString(key)
                End If
            End If
        textReader = Nothing

which locks the config file.  I try to write to it later and get file not found error. Then I stop the service and the config file is available again.  I thought closing the reader and setting it to nothing would work.  Is this the correct way to read this XML or do I need to stop the service before writing to the XML file.  I really do not want to stop the service.  I could also use another config file but that would add extra maintenance.  

Question by:courchjo
1 Comment

Accepted Solution

courchjo earned 0 total points
ID: 13762327
I found my problem.  I need to put function in try and catch.  The textReader.close and textreader = nothing is never being called after the return.  Since app is a service the reader never gets closed and the file is not released.


Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month15 days, 20 hours left to enroll

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question