473,396 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Two programs accessing an XML file as a dataset.

UJ
I have two programs that run at the same time. One creates an XML file of a
dataset, the other reads the file. They don't appear to be doing it at the
same time. Every once in a while, the XML file appears to get corrupt and
needs to be recreated. (The one reading gets a message about the root not
being valid.) I've tried putting a mutex in so that I know the file is only
in use by one and that didn't seem to work. I've tried having the writer
create a file under a different name, write the file and then rename it.
Still a problem.

The file isn't terribly big (only about 5 records with 4 fields each) and
I'm getting to the point that I may end up writing the stuff to the registry
because I know that that works.

Has anybody seen anything like this before? I must be missing something.....

TIA - Jeff.
Aug 17 '06 #1
2 1578
When you say corrupted, what were the file contents? And are you sure the
mutex was shared between the processes?
How are you accessing the files? XmlWriter/XmlReader?
XmlDocument.Save/.Load? what? (e.g. corruption if using XmlWriter could be
due to leaving old data at the end of the file (after your new xml) when
writing to the FileStream).

Also - if the corruption is due to concurrent access, taking out exclusive
file access might help; the second caller would get an exception, but at
least the file would be left intact.

Marc
Aug 17 '06 #2
Hi,
The creator should open the file with exclusive lock, write the data and
close it. Only then the reader could open it. You do not explain how the
reader knows that a new file is ready. You could do so by using
FileSystemWatcher. I recommend to not use the data file itself but another
file with the same name but a different extension (.flag for example) .
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"UJ" <fr**@nowhere.comwrote in message
news:OJ**************@TK2MSFTNGP05.phx.gbl...
>I have two programs that run at the same time. One creates an XML file of a
dataset, the other reads the file. They don't appear to be doing it at the
same time. Every once in a while, the XML file appears to get corrupt and
needs to be recreated. (The one reading gets a message about the root not
being valid.) I've tried putting a mutex in so that I know the file is only
in use by one and that didn't seem to work. I've tried having the writer
create a file under a different name, write the file and then rename it.
Still a problem.

The file isn't terribly big (only about 5 records with 4 fields each) and
I'm getting to the point that I may end up writing the stuff to the
registry because I know that that works.

Has anybody seen anything like this before? I must be missing
something.....

TIA - Jeff.


Aug 17 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: George Grodentzik | last post by:
I created a typed dataset from which I am trying to access the data. When I use the following code to access a row string name =dataset.person.firstName I receive an error...
2
by: KimD | last post by:
I'm filling a dataset with the return of a stored procedure. The dataset contains a number of tables which I am naming within the stored procedure, however when I try to access the tables using the...
4
by: Eugen Walcher | last post by:
Hello all, I've tried posting this same question on other newsgroups with no luck. This group seems to have a lot more activity so I apologize if you have seen it before. I'm trying to...
2
by: James Zhuo | last post by:
Accessing Items in a Collection works with the as suggested by Kevin and Chris (thx) But when i tried to use the same technic with databinding within the aspx file, it doesn't seem to work. This...
0
by: N. Demos | last post by:
Hello, I'm having problems accessing a complex XML child node (latitude & longitude), and passing it to a function when the XML file has been read into a DataSet. Specifically, the returned object...
3
by: Mike N. | last post by:
Using VB.Net and ADO: I've created a public variable on my main form and set it to = a dataset which was crrated with the designer. I have another form with a datagrid on it. In the designer,...
4
by: SteveT | last post by:
I am wanting to populate several treeviews, one for the <TRs> group and one for the <TGsgroup. Is there a simplier way to populate the Treeview than the one I did below? It seems difficult to...
3
by: Robert Bravery | last post by:
HI all, I have an xml file, I need to be able to read the data into strong typed dataset for further use in my application Can someone point me to documentation as to how I can do this. I have...
2
ssnaik84
by: ssnaik84 | last post by:
Hello, I have hosted a website on GoDaddy.com. It's a share hosting. I am using XML file as a database. That means, I am reading and writing data into XML file instead of regular RDBMS (MySQL, MS...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.