473,803 Members | 2,937 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Process.Start fails on separate thread

I use Process.Start to open a URL in the user's browser.

When I call the function normally, it works fine. However, when I call it
from a separate thread, I get an error: "The requested section was not
present in the activation context".

The only C# newsgroup thread dealing with this error blames it on a Main
function that is missing the [STAThread] attribute - but my Main function
has this attribute.

What can I do to work around this?

P.

--
www.CL4.org
Nov 15 '05 #1
4 2772
can you post the relevant code?

--
Regards,
Alvin Bruney
Got tidbits? Get it here...
http://tinyurl.com/2bz4t
"Paul E Collins" <fi************ ******@CL4.org> wrote in message
news:bt******** **@sparta.btint ernet.com...
I use Process.Start to open a URL in the user's browser.

When I call the function normally, it works fine. However, when I call it
from a separate thread, I get an error: "The requested section was not
present in the activation context".

The only C# newsgroup thread dealing with this error blames it on a Main
function that is missing the [STAThread] attribute - but my Main function
has this attribute.

What can I do to work around this?

P.

--
www.CL4.org

Nov 15 '05 #2
Sure, but your "separate" thread is not initialized for STA I guess.

Willy.

"Paul E Collins" <fi************ ******@CL4.org> wrote in message
news:bt******** **@sparta.btint ernet.com...
I use Process.Start to open a URL in the user's browser.

When I call the function normally, it works fine. However, when I call it
from a separate thread, I get an error: "The requested section was not
present in the activation context".

The only C# newsgroup thread dealing with this error blames it on a Main
function that is missing the [STAThread] attribute - but my Main function
has this attribute.

What can I do to work around this?

P.

--
www.CL4.org

Nov 15 '05 #3
"Willy Denoyette [MVP]" <wi************ *@pandora.be> wrote:
your "separate" thread is not initialized for STA I guess.


Adding [STAThread] to all functions called by that thread doesn't fix the
problem. Is this what you mean by "initializi ng for STA"?

Any other suggestions?

P.
Nov 15 '05 #4
No, you have to initialize the thread by setting the ApartmentState
property, preferably before calling Thread.Start.

<code snippet>

thread = ....
thread.Apartmen tState = ApartmentState. STA;
thread.Start();
....
</code snippet>
Willy.

"Paul E Collins" <fi************ ******@CL4.org> wrote in message
news:bt******** **@titan.btinte rnet.com...
"Willy Denoyette [MVP]" <wi************ *@pandora.be> wrote:
your "separate" thread is not initialized for STA I guess.


Adding [STAThread] to all functions called by that thread doesn't fix the
problem. Is this what you mean by "initializi ng for STA"?

Any other suggestions?

P.

Nov 15 '05 #5

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

Similar topics

5
2720
by: Jon Perez | last post by:
Running the following under Linux creates 3 processes instead of 2. Once the started thread exits, 2 processes still remain. Why? import thread from thread import start_new_thread def newthread(): print "child"
12
2955
by: serge calderara | last post by:
Dear all, I have an application which is suppose to start another executable process. As soon as that process is running, I need to retrive its handle. The problem of the particular process I am starting is that it has a welcome window first which gets displayed and then the real windows after a while,in other words it means that the process name is the same, but the handle I need to retrive is the one from the final window and not the...
4
6598
by: Prince Kumar | last post by:
I joined a company recently and they have a java program which hangs (does nothing) after a while. This is no way consistent. It could succeed quite a few times and can fail a few other times. There is no consistency when it fails. Could anyone here shed some light on how to debug/resolve the issue. I guess IBM looked at the issue and were not able to pinpoint where the issue is. When the program hangs and when force the DB2...
4
13164
by: Steve | last post by:
I am using Diagnostics.Process to, well.. execute a process. I would like to display the output of the process to my UI as it is created. For example, ping www.yahoo.com will slowly output each result. I want to display that output as it happens in my UI. I don't see a clean way to do this. After my Start() call, I made a call to StandardOutput.ReadToEnd() but it appears to hang until the process finishes (makes sense) But what do...
12
2377
by: Raymond Lewallen | last post by:
How to wait for a process to stop completion is my goal. Obviously, the looping while waiting for the HasExited property is not a solution.. but thats the best I can come up off the top of my head. Natuarally it will not work. I expect it to use up all resources looping, which will not allow the process to complete. The process takes about 60 seconds, because the .bat file it is calling is rebuilding mulitple .NET solutions and projects...
1
4746
by: Steve | last post by:
I have a bit of "login authentication" code that in the event of a server error, connection error, etc will take a Looooooong time to timeout. I wanted to redesign it to call the DAL method in a separate thread (easy enough) w/ a callback for when it's done. The area I'm having trouble with is once I determine the timeout period has elapsed, how do I kill the thread safely? I asked a threading question here awhile ago and some kind...
2
3225
by: Anbu | last post by:
Hi all, I'm creating processes of a console based application. After proc.Start() the process is not getting terminated and the thread keeps waiting for some reponse from the process. Now I need to kill the process if it takes more time. Process proc = new Process(); proc.StartInfo.FileName = "application";
5
1820
by: ags5406 | last post by:
I've a Windows Service that keeps a particular executable running. If the executable fails for whatever reason, the Service restarts it. Right now I'm using a loop to check if the process is running. I started with an infinite loop that ate up all of my resources, but then added a 2 second pause after every check, which seems to have mostly eliminated the problem of my resources being used up. However, I'm wondering if there is a...
5
9734
by: Markgoldin | last post by:
I am searching for a solution of sending messages from not .Net process into a .Net process written in C#. I have gone already thru sockets solution and have porblems with it. I am not a C# coder dont kill :) I am thinking about something like this: A remote non .Net process has a window with a name known to .Net program. Can .Net program somehow process that window using window's title and extracting a text from it? What other solutions...
0
9703
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10317
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10300
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9127
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7607
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5503
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4277
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
3
2974
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.