D
Doug Kent
Hi,
I am using a STA thread to run a COM object.
On a couple of machines the thread runs fine. On another machine the thread
won't start, and no exceptions are thrown.
This code is running in a web service implemented using C#, ASP.NET 1.1, IIS
5.1, Windows 2000 Server.
Any suggestions appreciated! Here is some code. The method
xmlLoader.Load() is never invoked.
To start the thread:
XmlBulkLoader xmlLoader = new XmlBulkLoader();
ThreadStart workThreadDelegate = new ThreadStart(xmlLoader.Load);
Thread workThread = new Thread(workThreadDelegate);
workThread.ApartmentState = ApartmentState.STA;
workThread.Name = "XMLBulkLoader";
workThread.Start();
workThread.Join();
The code that is not running when it should (xmlLoader.Load):
public class XmlBulkLoader
{
public void Load()
{
ADODB.Stream xmlDataStream = null;
try
{
xmlDataStream = new ADODB.StreamClass();
xmlDataStream.Open(System.Type.Missing,
ADODB.ConnectModeEnum.adModeUnknown,
ADODB.StreamOpenOptionsEnum.adOpenStreamUnspecified,
null, null);
xmlDataStream.WriteText(_xmlData, ADODB.StreamWriteEnum.adWriteChar);
xmlDataStream.Position = 0;
SQLXMLBulkLoad3 objBL = new SQLXMLBulkLoad3();
objBL.ConnectionString=_dbConnection;
objBL.ErrorLogFile = Path.Combine(_logFilePath, "sqlbulkloaderror.log");
objBL.CheckConstraints = true;
objBL.Transaction = true;
objBL.XMLFragment = false;
objBL.SchemaGen = false;
objBL.KeepIdentity = false;
objBL.KeepNulls= false;
objBL.IgnoreDuplicateKeys = false;
objBL.ForceTableLock = false;
objBL.SGDropTables = false;
objBL.Execute(_schemaFile, xmlDataStream);
}
catch(Exception ex)
{
exception = ex;
}
finally
{
if (xmlDataStream != null)
{
xmlDataStream.Close();
}
}
}
}
I am using a STA thread to run a COM object.
On a couple of machines the thread runs fine. On another machine the thread
won't start, and no exceptions are thrown.
This code is running in a web service implemented using C#, ASP.NET 1.1, IIS
5.1, Windows 2000 Server.
Any suggestions appreciated! Here is some code. The method
xmlLoader.Load() is never invoked.
To start the thread:
XmlBulkLoader xmlLoader = new XmlBulkLoader();
ThreadStart workThreadDelegate = new ThreadStart(xmlLoader.Load);
Thread workThread = new Thread(workThreadDelegate);
workThread.ApartmentState = ApartmentState.STA;
workThread.Name = "XMLBulkLoader";
workThread.Start();
workThread.Join();
The code that is not running when it should (xmlLoader.Load):
public class XmlBulkLoader
{
public void Load()
{
ADODB.Stream xmlDataStream = null;
try
{
xmlDataStream = new ADODB.StreamClass();
xmlDataStream.Open(System.Type.Missing,
ADODB.ConnectModeEnum.adModeUnknown,
ADODB.StreamOpenOptionsEnum.adOpenStreamUnspecified,
null, null);
xmlDataStream.WriteText(_xmlData, ADODB.StreamWriteEnum.adWriteChar);
xmlDataStream.Position = 0;
SQLXMLBulkLoad3 objBL = new SQLXMLBulkLoad3();
objBL.ConnectionString=_dbConnection;
objBL.ErrorLogFile = Path.Combine(_logFilePath, "sqlbulkloaderror.log");
objBL.CheckConstraints = true;
objBL.Transaction = true;
objBL.XMLFragment = false;
objBL.SchemaGen = false;
objBL.KeepIdentity = false;
objBL.KeepNulls= false;
objBL.IgnoreDuplicateKeys = false;
objBL.ForceTableLock = false;
objBL.SGDropTables = false;
objBL.Execute(_schemaFile, xmlDataStream);
}
catch(Exception ex)
{
exception = ex;
}
finally
{
if (xmlDataStream != null)
{
xmlDataStream.Close();
}
}
}
}