Exception lors de l'utilisation de FolderBrowserDialog

Je suis l'Exception suivante lorsque vous essayez d'utiliser FolderBrowserDialog:
System.Threading.ThreadStateException: 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.

J'ai Googlé ce problème de manière approfondie et les solutions que tout le monde suggère semblent être de mettre [STAThreadAttribute] au-dessus de la Principale méthode pour supprimer toutes les dll du dossier de Débogage, ou d'utiliser le Invoke méthode. J'ai essayé toutes ces, et je reçois toujours la même exception.

Voici le code:

public partial class Form1 : Form
{
    public event EventHandler ChooseLocationHandler = null;

    public string DestFolder
    {
        set { textBox1.Text = value; }
        get { return textBox1.Text; }
    }

    public Form1()
    {
        InitializeComponent();
    }

    private void ChooseLocationButton_Click(object sender, EventArgs e)
    {
        if (ChooseLocationHandler != null)
            ChooseLocationHandler(this, e);
    }
}

Et dans mon présentateur est la suivante:

public partial class Presenter
{
    Form1 myForm;
    public Presenter()
    {
        myForm = new Form1();
        myForm.ChooseLocationHandler += ChooseLocationHandler;
        myForm.Show();
    }

    public void ChooseLocationHandler(object obj, EventArgs e)
    {
        Form1 sender = (Form1)obj;

        FolderBrowserDialog fbd = new FolderBrowserDialog();
        fbd.RootFolder = System.Environment.SpecialFolder.MyComputer;
        fbd.ShowNewFolderButton = true;
        if (fbd.ShowDialog() == DialogResult.Cancel)
            return;

        sender.DestFolder = fbd.SelectedPath;
    }
}

Je suis de l'Exception sur les log.ShowDialog().

InformationsquelleAutor Daniel | 2011-07-28