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

Dialog Threading error

MAF
I recently updated a simple program that uses a filedialog control to locate
a file. When I try and run the following code I get this error:

Current thread must be set to single thread apartment (STA) mode before OLE
calls can be made. Ensure that your Main function has STAThreadAttribute
marked on it. This exception is only raised if a debugger is attached to the
process.

Here is the code

this.openFileDialog1.FileName = this.txtCompilePath.Text;

DialogResult result = openFileDialog1.ShowDialog(this);

if (openFileDialog1.ShowDialog() == DialogResult.OK)

{

this.txtCompilePath.Text = openFileDialog1.FileName;

}

Jan 17 '06 #1
2 1565
And did you "Ensure that your Main function has STAThreadAttribute ..." ?

Willy.

"MAF" <mf*****@henwoodenergy.com> wrote in message
news:Ov**************@TK2MSFTNGP15.phx.gbl...
|I recently updated a simple program that uses a filedialog control to
locate
| a file. When I try and run the following code I get this error:
|
| Current thread must be set to single thread apartment (STA) mode before
OLE
| calls can be made. Ensure that your Main function has STAThreadAttribute
| marked on it. This exception is only raised if a debugger is attached to
the
| process.
|
| Here is the code
|
| this.openFileDialog1.FileName = this.txtCompilePath.Text;
|
| DialogResult result = openFileDialog1.ShowDialog(this);
|
| if (openFileDialog1.ShowDialog() == DialogResult.OK)
|
| {
|
| this.txtCompilePath.Text = openFileDialog1.FileName;
|
| }
|
|
|
Jan 17 '06 #2


Thank you that fixed the problem

*** Sent via Developersdex http://www.developersdex.com ***
Jan 18 '06 #3

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

Similar topics

4
by: Alexander | last post by:
Hi, I have written a program that takes on some operations much more time than I expected. As I have seen users clicking wildly on the screen to make something happen, I want to follow the...
13
by: RCS | last post by:
I have a UI that needs a couple of threads to do some significant processing on a couple of different forms - and while it's at it, update the UI (set textboxes, fill in listviews). I created a...
2
by: Vjay77 | last post by:
In this code: Private Sub downloadBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) If Not (Me.downloadUrlTextBox.Text = "") Then Me.outputGroupBox.Enabled = True...
6
by: Samuel R. Neff | last post by:
I'm having weird results with a form that is already displayed modally (via ShowDialog) displaying a second form via ShowDialog. The last form is not modal even though it's called with ShowDialog....
3
by: Dustin Davis | last post by:
I'm doing image conversion in my application and it seems to take some time on some tasks. I'd like to show a "Converting..." type message in a dialog box or splash screen of sorts. The problem...
3
by: AboutJAV | last post by:
Hi, I created a child dialog to tell the user that there is a loading of data from the database. When the loading is done, the child dialog will close. The child dialog contains a custom control...
5
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using vs2005, .net 2.0. I have a form with crystal Viewer that I call as showdialog. I want to give the user an option to cancel out of it is it's taking too long to process. Is there a...
4
by: forest demon | last post by:
i've seen previous posts somewhat related to this, so i apologize if this is redundant. I have a main form with separate threads. When showing a dialog like <dialog>.ShowDialog(), it functions...
6
by: kdikert | last post by:
I have a worker thread, and when the worker is done I want it to show a popup dialog. The sample application below demonstrates this. There are two buttons: a "Show dialog" button which immediately...
6
by: Scott Gravenhorst | last post by:
Windows XP SP3 My application is set to open a SaveFile dialog when an exit is requested. When I click the app's close button, the save dialog opens, but when I click to change the folder, the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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:
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
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,...
0
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...

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.