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)