473,320 Members | 1,947 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Getting asp.net to run in an STA?

Hi.

I have a very annoying problem. I have a very complex application that has
been converted from COM/COM+ C++ to C#.
The interface for my application is proprietary xml over http implemented
previously in an ASP page, now it is in an ASPX page.

The problem is my application uses a 3rd party COM object that has been
marked as an STA component. Therefore I have to run my business logic inside
an STA (until I get rid of this COM component).

I did manage to get it to work by implementing this code in my ASPX page

Thread thread = new Thread( new ThreadStart( execute ) );

thread.ApartmentState = ApartmentState.STA;

thread.Start();

while ( thread.ThreadState != ThreadState.Stopped )

Thread.Sleep( 100 );

The problem is, the debugger doesn't like this thread-change in my aspx
page. Somethimes it hangs for a minute, sometimes Visual Studio ( ver.
2003 ) crashes.

Therefore I'd like to know if it is possible to get asp.net to run page
handling inside an STA thread ( doesn't seem like it for what I've read -
but maybe there's a hidden switch )

Thanks in advance,

Peter Strĝiman
Nov 18 '05 #1
3 3563
Add an aspcompat="true" attribute to your @Page directive.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Peter Strĝiman" <blah@blahblahblah> wrote in message
news:uv**************@tk2msftngp13.phx.gbl...
Hi.

I have a very annoying problem. I have a very complex application that has
been converted from COM/COM+ C++ to C#.
The interface for my application is proprietary xml over http implemented
previously in an ASP page, now it is in an ASPX page.

The problem is my application uses a 3rd party COM object that has been
marked as an STA component. Therefore I have to run my business logic inside an STA (until I get rid of this COM component).

I did manage to get it to work by implementing this code in my ASPX page

Thread thread = new Thread( new ThreadStart( execute ) );

thread.ApartmentState = ApartmentState.STA;

thread.Start();

while ( thread.ThreadState != ThreadState.Stopped )

Thread.Sleep( 100 );

The problem is, the debugger doesn't like this thread-change in my aspx
page. Somethimes it hangs for a minute, sometimes Visual Studio ( ver.
2003 ) crashes.

Therefore I'd like to know if it is possible to get asp.net to run page
handling inside an STA thread ( doesn't seem like it for what I've read -
but maybe there's a hidden switch )

Thanks in advance,

Peter Strĝiman

Nov 18 '05 #2
In the Page directive, set the AspCompat attribute as true, and the page can
be executed on an STA.

<%@ Page AspCompat="true" ... %>

--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--

"Peter Strĝiman" <blah@blahblahblah> wrote in message
news:uv**************@tk2msftngp13.phx.gbl...
Hi.

I have a very annoying problem. I have a very complex application that has
been converted from COM/COM+ C++ to C#.
The interface for my application is proprietary xml over http implemented
previously in an ASP page, now it is in an ASPX page.

The problem is my application uses a 3rd party COM object that has been
marked as an STA component. Therefore I have to run my business logic
inside
an STA (until I get rid of this COM component).

I did manage to get it to work by implementing this code in my ASPX page

Thread thread = new Thread( new ThreadStart( execute ) );

thread.ApartmentState = ApartmentState.STA;

thread.Start();

while ( thread.ThreadState != ThreadState.Stopped )

Thread.Sleep( 100 );

The problem is, the debugger doesn't like this thread-change in my aspx
page. Somethimes it hangs for a minute, sometimes Visual Studio ( ver.
2003 ) crashes.

Therefore I'd like to know if it is possible to get asp.net to run page
handling inside an STA thread ( doesn't seem like it for what I've read -
but maybe there's a hidden switch )

Thanks in advance,

Peter Strĝiman

Nov 18 '05 #3
Hi, I'm not sure but did you try that:

Thread t = new Thread(new ThreadStart(Run));
t.Start();
t.Join();

when u join the main thread wait until your thread will finish.

hope it help...
Nov 18 '05 #4

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

Similar topics

2
by: Eyal | last post by:
Hey, I would appriciate if anyone can help on this one: I have a java object/inteface having a method with a boolean parameter. As I'm trying to call this method from a javascript it fails on...
5
by: Francis Bell | last post by:
I just found that my fin stream is not getting passed to my readInASpinnerbait function. Here's what I have: string readInFirstChars(ifstream &fin) { char first; string print; while...
8
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported...
0
by: Si | last post by:
I'm writing an HttpModule to intecept web method calls and retrieve custom authentication information from their SOAP headers. I have the httpModules tag in web.config and that appears to be...
3
by: dei3cmix | last post by:
Hey, I am having a problem with a program I am working on. Basically, the first part of the program gets input from a file using cin.getline. Then the second part, (still in the same main as the...
32
by: paul | last post by:
HI! I keep on getting this error and I have tried different things but I am not sure how to send the expiring date. The error that I am getting in Firefox 1.5 is "Error: expires.toGMTString is...
2
by: MSK | last post by:
Hi, Continued to my earlier post regaring "Breakpoints are not getting hit" , I have comeup with more input this time.. Kindly give me some idea. I am a newbie to .NET, recently I installed...
4
by: R.Manikandan | last post by:
Hi In my code, one string variable is subjected to contain more amount of characters. If it cross certain limit, the string content in the varabile is automatically getting truncated and i am...
4
by: imaloner | last post by:
I am posting two threads because I have two different problems, but both have the same background information. Common Background Information: I am trying to rebuild code for a working,...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shĉllîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.