OpenFile Dialog Control in C# execution problemI opened the new project in that double clicked on OpenFileDialog control. Then I taken one textbox made it as multiline below that one button under that button I written the code which I mentioned below
int size = -1;
DialogResult result = openFileDialog1.ShowDialog();
if (result == DialogResult.OK)
string file = openFileDialog1.FileName;
string text = File.ReadAllText(file);
size = text.Length;
Here after execution whenever I am going for open button its showing some exception error like below
"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".
I am a beginner so since from two days I am trying to sort it out but I am unable to do it, so please help me.