0

I have an intermittent “bug” in my code. As per the code below, my app crashes when it tries to assign the table (0) in the dsAlerts dataset to a table, as in the last line of the supplied code, with the error blah.exe has exited with code -1073741819 (0xc0000005) 'Access violation'.

I have tried to, Move the xml file to the desktop, to test security rights the program files directory, and run the app as administrator, but it will work once or twice and then start throwing the error.

The XML file the app is reading is created by a service I wrote that uses the dataset.writexml function to create the file every 30 min.

I have three options as to what is causing this error, 1. The Service that creates the file in the first place is hogging the file. The data query and write takes about 5 minutes 2. For some reason the previous run of the application is holding the file 3. I have no clue what I am doing.

My code is below, any feedback would be appreciated.

Regards Rhys

Dim myXMLfile As String = "C:\Program Files\Aloe FM Audit\Data\dsFmAuditAlerts.xml"
Dim dsAlerts As New DataSet()
Dim dtFmAuditAlerts As New DataTable
Dim fsReadXml As New System.IO.FileStream(myXMLfile, System.IO.FileMode.Open)

dsAlerts.ReadXml(fsReadXml)
fsReadXml.Flush()
fsReadXml.Close()

dtFmAuditAlerts = dsAlerts.Tables(0)
Rhys Gottwald
  • 71
  • 2
  • 7
  • or #4 - Programs are usually denied access to `\Program Files\...` which is why `Users\... exists. If it takes a while to create the file, and your app is running on a timer or FSW it could well *also* try to opent eh file while a lock is on it. Is the other app/service yours? – Ňɏssa Pøngjǣrdenlarp Feb 09 '15 at 16:09
  • Thank you for the feedback, I will move the file and see if that is the case. I will also add a check if locked option. Yes the other service is mine too, and other advice is MORE than welcome. – Rhys Gottwald Feb 10 '15 at 07:23

0 Answers0