473,396 Members | 1,942 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,396 software developers and data experts.

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 2753
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.btinternet.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.btinternet.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 "initializing 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.ApartmentState = ApartmentState.STA;
thread.Start();
....
</code snippet>
Willy.

"Paul E Collins" <fi******************@CL4.org> wrote in message
news:bt**********@titan.btinternet.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 "initializing 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
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...
12
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...
4
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....
4
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...
12
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...
1
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...
2
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...
5
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...
5
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
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,...

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.