Hello
Please Help me
I have to use FolderBrowserDialog.
BUT...
Error Message :
System.Threading.ThreadStateException: 'OLE calls require the current thread to be in single-threaded apartment (STA) mode.
Make sure the indicated STAThreadAttribute exists in the Main function.
This exception only occurs when a debugger is attached to the process.
--------------------
I shouldn't use [STAThread] here.
Please Help me
I have to use FolderBrowserDialog.
BUT...
Error Message :
System.Threading.ThreadStateException: 'OLE calls require the current thread to be in single-threaded apartment (STA) mode.
Make sure the indicated STAThreadAttribute exists in the Main function.
This exception only occurs when a debugger is attached to the process.
--------------------
I shouldn't use [STAThread] here.
C#:
namespace NotSTA
{
class Program
{
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
}
}
namespace NotSTA
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
MessageBox.Show(folderBrowserDialog1.SelectedPath);
}
}
}
}
C#:
namespace NotSTA
{
class Program
{
[STAThread] //<================ I shouldn't use [STAThread] Here.
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
}
}
Please Help me