Results 1 to 4 of 4

Thread: [RESOLVED] OpenFileDialog ThreadStateException

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Posts
    146

    Resolved [RESOLVED] OpenFileDialog ThreadStateException




    How do I solve it?
    Last edited by winterslam; Jun 29th, 2009 at 08:29 PM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: OpenFileDialog ThreadStateException

    I'm not sure how that could happen unless you have specifically removed the STAThread attribute from your Main method. This is what your Program.cs file should look like by default:
    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Windows.Forms;
    
    namespace WindowsFormsApplication1
    {
        static class Program
        {
            /// <summary>
            /// The main entry point for the application.
            /// </summary>
            [STAThread]
            static void Main()
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new Form1());
            }
        }
    }
    give or take a 'using' directive.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Posts
    146

    Re: OpenFileDialog ThreadStateException

    Thanks


    Actually it is this wizard project
    http://www.vbforums.com/showthread.php?t=574281
    The original source has no Program.cs.



    By the way, does STA mean that I cannot create multiple threads in the application?

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: OpenFileDialog ThreadStateException

    Quote Originally Posted by winterslam View Post
    does STA mean that I cannot create multiple threads in the application?
    What happened when you tried? What did you find when you researched the STAThread attribute?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width