Using:
.Net (happens to be VB but same with C#) 2.0
SQLXML4
SQL Server 2005
I've got a multithreaded .Net application that uses the SQLXmlBulkLoad call
and I'm not convinced the COM object is being released properly. The code is
also called often and I'm not sure if I should be creating the object each
time, or reusing it. I've tried reusing it (one object for all threads with
a lock or one object per thread), but because of the multithreaded nature of
the app, can't get this to work. Each thread is STA...
The Handle count keeps increasing in the application, and eventually it
crashes and I've narrowed it down to the SQL XML Bulk Load bit.
Any help would be appreciated.
The code for this is here:
' load up the SQLXML's bulkload object
Dim bulkLoadComObje ct As SQLXMLBULKLOADL ib.SQLXMLBulkLo ad4 = Nothing
Try
bulkLoadComObje ct = New SQLXMLBULKLOADL ib.SQLXMLBulkLo ad4
bulkLoadComObje ct.ConnectionSt ring = _connectionStri ng
bulkLoadComObje ct.KeepIdentity = False
bulkLoadComObje ct.Execute(sche maFilename, tempFilename)
Finally
' clear up
If (Not bulkLoadComObje ct Is Nothing) Then
System.Runtime. InteropServices .Marshal.Releas eComObject(bulk LoadComObject)
End If
bulkLoadComObje ct = Nothing
File.Delete(tem pFilename)
End Try
.Net (happens to be VB but same with C#) 2.0
SQLXML4
SQL Server 2005
I've got a multithreaded .Net application that uses the SQLXmlBulkLoad call
and I'm not convinced the COM object is being released properly. The code is
also called often and I'm not sure if I should be creating the object each
time, or reusing it. I've tried reusing it (one object for all threads with
a lock or one object per thread), but because of the multithreaded nature of
the app, can't get this to work. Each thread is STA...
The Handle count keeps increasing in the application, and eventually it
crashes and I've narrowed it down to the SQL XML Bulk Load bit.
Any help would be appreciated.
The code for this is here:
' load up the SQLXML's bulkload object
Dim bulkLoadComObje ct As SQLXMLBULKLOADL ib.SQLXMLBulkLo ad4 = Nothing
Try
bulkLoadComObje ct = New SQLXMLBULKLOADL ib.SQLXMLBulkLo ad4
bulkLoadComObje ct.ConnectionSt ring = _connectionStri ng
bulkLoadComObje ct.KeepIdentity = False
bulkLoadComObje ct.Execute(sche maFilename, tempFilename)
Finally
' clear up
If (Not bulkLoadComObje ct Is Nothing) Then
System.Runtime. InteropServices .Marshal.Releas eComObject(bulk LoadComObject)
End If
bulkLoadComObje ct = Nothing
File.Delete(tem pFilename)
End Try
Comment