Hello there,
I'm having problem when running my Windows Forms program.
In the program, I have a button that calls OpenFileDialog's ShowDialog() everytime it clicked.
public partial class MyProgram : Form { private Button myButton; private OpenFileDialog openFD; private string filePath; public MyProgram() { InitializeComponent(); myButton = new Button(); openFD = new OpenFileDialog(); filePath = string.Empty; myButton.Text = "Browse"; myButton.Click += new EventHandler(ShowOpenDialog); } private ShowOpenDialog(object sender, EventArgs e) { if(openFD.ShowDialog() == DialogResult.OK) // Here { filePath = openFD.FileName; } } }
But when I run the program, everytime I clicked the "Browse" (myButton) button, I got a "MyProgram has encountered a problem and needs to close. We are sorry for the inconvenience." error. When I clicked on the "What data does this error report contain?" link, the Error signature contains
EventType : clr20r3 P1 : myprogram.exe P2 : 1.0.0.0 P3 : 4a49b0bf P4 : system.windows.forms P5 : 2.0.0.0 P6 : 4889dee7 P7 : 188f P8 : 32 P9 : system.typeloadexception
Any idea?