Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Garbage Collection... Finalize

Status
Not open for further replies.

krionic

Programmer
Jun 5, 2004
6
US
Hello. Wonder if anyone knows a solution to my little problem.

From a form I populate a dataset using

Code:
Dim obj As New nsMain.clsMain
dsdataset = obj.getXMLData("E:names.xml")
and getXMLData is a function in a seperate class

Code:
Public Shared Function getXMLData(loc As String, name As String) As DataSet
			
   Dim dsDataSet As New DataSet(name)
   Dim fsReadXml As New System.IO.FileStream (loc, System.IO.FileMode.Open)
   Dim myXmlReader As New System.Xml.XmlTextReader(fsReadXml)
   dsDataSet.ReadXml(myXmlReader)

   myXmlReader.Close()
   Return dsDataSet

   Exit Function
End Function

When I make another call to a different function (one that writes xml to the file) I am told that the file is in use by another process.

Apparently in .net NOTHING no longer works like it did in VB6.

I've tried messing with finalize() and dispose() but have had no luck.

How do I kill an object? I know its nothing else because I can strip out the code from the writeXML function and put it in the form and it works fine. Its only when I'm creating instances of a class that it tells me its being used by another process at the line which is calling writeXML function.

Thanks if anyone can help.
 
should be:
Code:
Dim obj As New nsMain.clsMain
dsdataset = obj.getXMLData("E:names.xml","Names")

I left out an argument but thats where the problem is. just wanted to correct here so that I dont throw anyone for a loop
 
Are you calling .Close on your FileStream object as well?

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Chip,

I tried that also. But didn't fix the problem. I stripped out all the filestream and xmlwriter stuff from the function and just used DataSet.WriteXML and DataSet.ReadXML and I didn't have a problem.

So my conclusion is that the readXML and writeXML methods of DataSet function perfectly. The above code was something I stripped and modified for .net from vb6. In the end, a single line of code did what I needed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top