सी # में कक्षा असाइनमेंट पर काम करना, मैं किसी भी त्रुटि के बिना प्रोग्राम क्रैश में आया (VS2010 की डीबग विंडो में जो लिखा गया है) को छोड़कर। क्रैश के कारण सामान्य कोड यहां दिया गया है:सी #: "प्रकार का पहला मौका अपवाद 'System.InvalidOperationException'"
public partial class Test : Form
{
public Test()
{
InitializeComponent();
}
private void Test_Load(object sender, EventArgs e)
{
ColumnHeader header;
header = new ColumnHeader();
header.Text = "#";
header.TextAlign = HorizontalAlignment.Center;
header.Width = 30;
listView1.Columns.Add(header);
TimerCallback tcb = this.UpdateListView;
System.Threading.Timer updateTimer = new System.Threading.Timer(tcb, null, 0, 1000);
}
public void UpdateListView(object obj)
{
ListViewItem item;
listView1.Items.Clear();
for (int i = 0; i < 10; i++)
{
item = new ListViewItem(i.ToString());
listView1.Items.Add(item);
}
}
}
... मुझे यहां क्या याद आ रही है?
** संपादित **
कोई त्रुटि है, इस कार्यक्रम सिर्फ समाप्त होता है आप को तोड़ने में Common Language Runtime Exception
के लिए Thrown
जाँच जब एक अपवाद हैं जैसे अगर मैं System.Environment.Exit(0);
A first chance exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll
The program '[4644] ProgramTest.vshost.exe: Managed (v4.0.30319)' has exited with code 0 (0x0).
The program '[4644] ProgramTest.vshost.exe: Program Trace' has exited with code 0 (0x0).
स्टैक ट्रेस? अपवाद फेंकने पर कोड की रेखा? –