Hello William,
I have definitely established that creating an XMLSerializer is causing this
problem - why that is happening is unclear because the XMLSerializer is not
touching the dataset the view is created from at all. It has to be some
kind of memory corruption problem.
I am serializing and deserializing some variables in XML that have nothing
directly to do with the dataset. (It is reading data stored in XML format
in a Visio VSD file and converting it from XML to a variable in memory) In
the following three lines of code, the second line that creates the
XMLSerializer is causing a problem. If I attempt to create a dataview on a
table in the dataset prior to the second line, I get three rows in the
dataview, if I do it immediately after the second line of code that creates
the new XMLSerializer, I get one row in the dataview: (Nothing has changed
in the dataset in between) This code is reading a list of attachments
stored in a Visio VSD file in XML format and putting the attachment list in
a variable called ShapeInfo.AttachmentInfo.
Dim ms As MemoryStream = MakeStream(XMLAttachmentList)
Dim s As New XmlSerializer(GetType(ShapeData.Attachments))
ShapeInfo.AttachmentInfo = CType(s.Deserialize(ms),
ShapeData.Attachments)
The dataset and the table I'm accessing in the dataset are not being touched
by the above code at all. The above code uses a memory stream which is
created by a routine called MakeStream which is shown below:
Friend Function MakeStream(ByVal InputString As String) As
MemoryStream
'***************************************************************************
*
' Makes a Memory Stream From a String
'***************************************************************************
*
Try
'----Create a Temporary Buffer to Hold Byte
Array----------------------------
Dim Buffer() As Byte
Dim ASCII As Encoding = Encoding.ASCII
'----Load Byte Array From
String---------------------------------------------
ReDim Buffer(InputString.Length + 1)
Buffer = ASCII.GetBytes(InputString.ToCharArray)
'----Return New Memory Stream Created from Byte
Array------------------------
Return New MemoryStream(Buffer)
Catch Exc As Exception
Throw New Exception("Error Atempting to Make a
Memory Stream", Exc)
End Try
End Function
Perhaps something in the above code is corrupting memory, but it has worked
reliably for a long time.
I have examined the rowstate of the three rows in the datatable I'm creating
the view from and they all show a rowstate of "Unchanged". I create the
view using the following code:
Dim dv As New DataView(DataSet1.Tables(TableName))
That code does not use a rowfilter or a rowstatefilter so it should select
all rows in the table. If I put a subroutine call to create the view prior
to creating the XMLSerializer and examine DV.Count I get three rows. If I
do the exact same thing after creating the XMLSerializer, I get one row.
Nothing in the dataset has changed in between and I've only executed one
instruction to create the XMLSerializer. This definitely looks like some
kind of memory corruption problem.
Thanks,
Chuck Cobb