-
Apr 6th, 2012, 06:00 PM
#1
Thread Starter
New Member
XML Files Not Closing
I've written a VB.NET program for a client that stores all of its data in XML files. I use the XMLReader to read the data into a dataset. When I run the sub to encrypt the XML file, I'll get the following message:
Error: mscorlib: The requested operation cannot be performed on a file with a user-mapped section open.
It doesn't happen all the time, so I know it does work. But on occassion, I'll get this message. I've been all over the forums and I've tried everything I've read to try and stop this error.
I close the reader object and set it equal to Nothing. I've even tried using DoEvents to make sure the object finished closing before running the Encrypt sub. Nothing has helped.
I develop on a x32 PC. It works fine on the development machine. But then, when the client runs it on a x64 PC, he gets these errors. Could the x64 system really be running so fast that the .Close() and the = Nothing and evern the .DoEvents() can't keep up?
-
Apr 9th, 2012, 08:20 AM
#2
Member
Re: XML Files Not Closing
Would you be able to post the actual code ?
-
Apr 15th, 2012, 01:21 PM
#3
Thread Starter
New Member
Re: XML Files Not Closing
Sorry for taking so long to post code. Here's a snapshot. I have a sub that decrypts the XML files and another the encrypts them. Throughout the programs, I call these subs when I need to access the info in the XML.
The program runs fine on 32-bit Windows. On 64-bit Windows, it works most of the time, but frequently shoots an error that the file is open while I'm trying to decrypt it.
It can happen anywhere in the program. Not necessarily in the same place twice. But it always works on the 32-bit machie. Here's a snippet of code that calls the decrypt/encrypt subs.
===== Begin Code =====
Public Shared Sub GetMemberTotalTime()
' Procedure for getting the list of All Employees from the
' Time Table
'
' Created by Xxx Xxxxxxxx
' Modified 2/24/12 by Xxx Xxxxxxxx
' Called from:
' formServiceQuery.formServiceQuery_Load
Try
' Declare the XML Reader
Dim xmlTime As System.Xml.XmlReader
' Declare the Dataset
datasetTime = New DataSet
' Declare the Dataview
dataviewTime = New DataView
' Declare the Datatable
datatableTime = New DataTable
' Decrypt the XML file to be read
classSharedSubs.DecryptTable(strDataPath & "tableTime.xml")
' Read the XML file into the XML Readers
xmlTime = System.Xml.XmlReader.Create(strDataPath & "tableTime.xml", New System.Xml.XmlReaderSettings())
' Read the contents of the XML Reader into the Dataset
datasetTime.ReadXml(xmlTime)
' Close the XML file
xmlTime.Close()
xmlTime = Nothing
' Encrypt the XML file after being read
classSharedSubs.EncryptTable(strDataPath & "tableTime.xml", "results")
Catch ex As Exception
MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OkOnly, "Error in Module: classSharedSubs\GetMemberTotalTime")
classProgramLoad.VerifyEncryptedDataFiles()
formV360.Close() ' Close the V360 Program.
End Try
End Sub ' 17) GetMemberTotalTime
===== EndCode =====
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|