473,586 Members | 2,839 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

thread won't start

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 workThreadDeleg ate = new ThreadStart(xml Loader.Load);
Thread workThread = new Thread(workThre adDelegate);
workThread.Apar tmentState = ApartmentState. STA;
workThread.Name = "XMLBulkLoader" ;
workThread.Star t();
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.StreamCla ss();
xmlDataStream.O pen(System.Type .Missing,
ADODB.ConnectMo deEnum.adModeUn known,
ADODB.StreamOpe nOptionsEnum.ad OpenStreamUnspe cified,
null, null);
xmlDataStream.W riteText(_xmlDa ta, ADODB.StreamWri teEnum.adWriteC har);
xmlDataStream.P osition = 0;
SQLXMLBulkLoad3 objBL = new SQLXMLBulkLoad3 ();
objBL.Connectio nString=_dbConn ection;
objBL.ErrorLogF ile = Path.Combine(_l ogFilePath, "sqlbulkloaderr or.log");
objBL.CheckCons traints = true;
objBL.Transacti on = true;
objBL.XMLFragme nt = false;
objBL.SchemaGen = false;
objBL.KeepIdent ity = false;
objBL.KeepNulls = false;
objBL.IgnoreDup licateKeys = false;
objBL.ForceTabl eLock = false;
objBL.SGDropTab les = false;
objBL.Execute(_ schemaFile, xmlDataStream);
}
catch(Exception ex)
{
exception = ex;
}
finally
{
if (xmlDataStream != null)
{
xmlDataStream.C lose();
}
}
}
}
Nov 19 '05 #1
5 1625
Dear Doug Kent

As far as I know,
In ASP.NET, the thread pool is a multithreaded apartment (MTA) by default.
And When which can affect the performance of traditional apartment-threaded
(ie STA - Single Threaded Apartment) Visual Basic 5 and Visual Basic 6
components

If it is a page (ie webpage you could have set the AspCompat Attribute of
the Page Directive to True)

AspCompat
=======
When set to true, this allows the page to be executed on a single-threaded
apartment (STA) thread. This allows the page to call STA components, such as
a component developed with Microsoft Visual Basic 6.0. Setting this attribute
to true also allows the page to call COM+ 1.0 components that require access
to unmanaged Active Server Pages (ASP) built-in objects. These are accessible
through the ObjectContext object or the OnStartPage method. The default is
false.
Note Setting this attribute to true can cause your page's performance to
degrade. For more information, see the Remarks section.

When the AspCompat attribute is set to true for a page, if you use a
constructor to create a COM component before the request is scheduled, it
will run on a multithreaded apartment (MTA) thread. Doing this causes
significant Web server performance degradation. To avoid this problem, create
COM components only from within one of the Page events (such as Page_Load,
Page_Init, and so on) or one of the Page methods. Be sure as well that the
objects are not created at page construction time. The following examples
demonstrate the incorrect and correct way to instantiate a COM object in an
AspCompat page. MyComObject is the component, and comObj is the instance of
the component.

In you case, since it is webservie,

ASP.NET WebServices calling Apartment-Threaded COM Components...

If you've ever had to call a VB6 Component from an ASP.NET (ASMX) XML Web
Service, you may (most probably) get threading errors. In ASP.NET Apps you
can mark the Page directive with "ASPCompat='tru e'" but there is not a
equivalent tag for Web Services. So, there's a few things you can do:

Put the VB Component in COM+ (Preferred if the COM Object is part of a
larger interaction, and you want fine control over your SOAP)

Figure out a different way to expose the COM Object as a Web Service,
perhaps with Classic ASP and SOAP Toolkit 3.0 (Quick if you just want to get
your component, but has larger design ramifications for big systems)

for futher infor please look into ...,

http://www.hanselman.com/blog/ASPNET...omponents.aspx

http://www.hanselman.com/blog/Catego...Web%20Services

@ Page
======
http://msdn.microsoft.com/library/de.../cpconPage.asp

COM Component Compatibility
=============== ====
http://msdn.microsoft.com/library/de...patibility.asp

COM Interoperabilit y
=============
http://samples.gotdotnet.com/quickst...ominterop.aspx

Developing High-Performance ASP.NET Applications
=============== =============== ===
http://msdn2.microsoft.com/en-us/library/5dws599a

bye
Venkat_KL

Nov 19 '05 #2
One more good article

Calling a COM object from a Web service in .NET

http://www.builderau.com.au/architec...9131286,00.htm

bye
venkat_kl
Nov 19 '05 #3
Thanks! I would like to know why the code works on some computers and not
others. I note that the computer on which it *doesn't* work is Windows 2000
Server, while the ones on which it *does* work are Windows XP Pro.

-d
Nov 19 '05 #4
OK, I found a computer with SQL Server 2000 on which the code *does* work.
So it is not that. There is some other difference.
Nov 19 '05 #5
Turns out a referenced dll was not present. Unfortunate that the thread
gave no clue.
Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1041
by: Phil | last post by:
I recently replaced my Toshiba 6100 laptop running XP Pro with a Dell Latitude D810 running XP Pro; since that time an application that I developed over a year ago has stopped working. I am using the same development environments, code, and third-party components. Nothing is different except the development computer. If I use my test app,...
23
6511
by: Jeff Rodriguez | last post by:
Here's what I want do: Have a main daemon which starts up several threads in a Boss-Queue structure. From those threads, I want them all to sit and watch a queue. Once an entry goes into the queue, grab it and run a system command. Now I want to make sure that system command doesn't hang forever, so I need some way to kill the command...
5
4016
by: Serge | last post by:
Hi, I am having a thread hang problem in my c# code. The example on the website: http://csharp.web1000.com/ is a simplified version of my problem. You will see in the form that a method TestThread increments a number in the textbox on the form. TestThread is called from a worker thread (2nd thread) using a TimerThread.
12
2317
by: Ricardo Pereira | last post by:
Hello all, I have a C# class (in this example, called A) that, in its constructor, starts a thread with a method of its own. That thread will be used to continuously check for one of its object's state and generate classe's A events "Connected" and "Disconnected". It looks something like this: "
7
439
by: Ivan | last post by:
Hi there My work on threads continues with more or less success. Here is what I'm trying to do: Class JobAgent is incharged for some tasks and when it's called it starts thread which performs the job. Application contains one list of agents that are idle at the moment and list of busy agents. In loop it checks if there are agents in idle...
8
1616
by: Jason Chu | last post by:
I have a webpage which uploads a big file onto access db. if the file is say around 30 megs, it'll take around a minute for it to get put into the access db. I didn't want the user to wait for it, so I decided to put it on a thread. The thread works, but not the way it should. One of my page will start the thread, and then forward the user to...
5
2206
by: taylorjonl | last post by:
I am completely baffled. I am writting a daemon application for my work to save me some time. The application works fine at my home but won't work right here at work. Basically I have a MainForm what has a Start/Stop button that starts and stops the processing thread. private void StartButton_Click(object sender, System.EventArgs e) {...
0
1077
by: Nick | last post by:
hi, I have a asp.net project. I want to start a thread in this project at some point to do some operations on database.Is there a limitation on this thread about how long it could run? Is it possible to make it run all the time to do monitor job? For me, looks like it works on my machine. But when I put it to the my webhost, public it,...
0
1520
by: Yue Fei | last post by:
I have a multi thread python code, threads can start immediately if I run on command line, but I can get them started right the way if I call the same code from C/C++. test code like this: from threading import Thread import thread class testThread(Thread): def __init__ (self, id): Thread.__init__(self) self.id = id def run(self):
0
7911
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7839
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8200
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8215
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3836
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.