Results 1 to 3 of 3

Thread: XML Files Not Closing

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2012
    Posts
    2

    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?

  2. #2
    Member
    Join Date
    Oct 2004
    Location
    Sunderland, UK
    Posts
    53

    Re: XML Files Not Closing

    Would you be able to post the actual code ?

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2012
    Posts
    2

    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
  •  



Click Here to Expand Forum to Full Width