• <i id='MNGHF'><tr id='MNGHF'><dt id='MNGHF'><q id='MNGHF'><span id='MNGHF'><b id='MNGHF'><form id='MNGHF'><ins id='MNGHF'></ins><ul id='MNGHF'></ul><sub id='MNGHF'></sub></form><legend id='MNGHF'></legend><bdo id='MNGHF'><pre id='MNGHF'><center id='MNGHF'></center></pre></bdo></b><th id='MNGHF'></th></span></q></dt></tr></i><div id='MNGHF'><tfoot id='MNGHF'></tfoot><dl id='MNGHF'><fieldset id='MNGHF'></fieldset></dl></div>

      <legend id='MNGHF'><style id='MNGHF'><dir id='MNGHF'><q id='MNGHF'></q></dir></style></legend>
    1. <small id='MNGHF'></small><noframes id='MNGHF'>

      <tfoot id='MNGHF'></tfoot>

        <bdo id='MNGHF'></bdo><ul id='MNGHF'></ul>

      1. C#:“'System.InvalidOperationException' 类型的第一次机会异常&qu

        C# : quot;A first chance exception of type #39;System.InvalidOperationException#39;quot;(C#:“System.InvalidOperationException 类型的第一次机会异常)

          <legend id='JHpdt'><style id='JHpdt'><dir id='JHpdt'><q id='JHpdt'></q></dir></style></legend>

              <tfoot id='JHpdt'></tfoot>

            • <small id='JHpdt'></small><noframes id='JHpdt'>

              <i id='JHpdt'><tr id='JHpdt'><dt id='JHpdt'><q id='JHpdt'><span id='JHpdt'><b id='JHpdt'><form id='JHpdt'><ins id='JHpdt'></ins><ul id='JHpdt'></ul><sub id='JHpdt'></sub></form><legend id='JHpdt'></legend><bdo id='JHpdt'><pre id='JHpdt'><center id='JHpdt'></center></pre></bdo></b><th id='JHpdt'></th></span></q></dt></tr></i><div id='JHpdt'><tfoot id='JHpdt'></tfoot><dl id='JHpdt'><fieldset id='JHpdt'></fieldset></dl></div>

                <tbody id='JHpdt'></tbody>
                <bdo id='JHpdt'></bdo><ul id='JHpdt'></ul>

                  本文介绍了C#:“'System.InvalidOperationException' 类型的第一次机会异常"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  在 C# 中进行类分配时,我遇到了一个程序崩溃,没有任何错误(除了在 VS2010 的调试窗口中写入的内容).这是导致崩溃的典型代码:

                  Working on a class assignment in C#, I came across a program crash without any error (except what's written in VS2010's debug window). Here is the typical code causing the crash :

                  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);
                          }
                  
                      }
                  }
                  

                  ...我在这里错过了什么?

                  ... what am I missing here?

                  ** 编辑 **

                  没有错误,程序只是结束,就像我调用 System.Environment.Exit(0);

                  There's no error, the program just ends like if I would call 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).
                  

                  推荐答案

                  如果在异常窗口(Ctrl+Alt+E 在 Visual Studio 中),那么当您在调试时抛出异常时执行应该中断.

                  If you check Thrown for Common Language Runtime Exception in the break when an exception window (Ctrl+Alt+E in Visual Studio), then the execution should break while you are debugging when the exception is thrown.

                  这可能会让您对正在发生的事情有所了解.

                  This will probably give you some insight into what is going on.

                  这篇关于C#:“'System.InvalidOperationException' 类型的第一次机会异常"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Force JsonConvert.SerializeXmlNode to serialize node value as an Integer or a Boolean(强制 JsonConvert.SerializeXmlNode 将节点值序列化为整数或布尔值)
                  Using JSON to Serialize/Deserialize TimeSpan(使用 JSON 序列化/反序列化 TimeSpan)
                  Could not determine JSON object type for type quot;Classquot;(无法确定类型“Class的 JSON 对象类型.)
                  How to deserialize a JSONP response (preferably with JsonTextReader and not a string)?(如何反序列化 JSONP 响应(最好使用 JsonTextReader 而不是字符串)?)
                  how to de-serialize JSON data in which Timestamp it-self contains fields?(如何反序列化时间戳本身包含字段的JSON数据?)
                  JSON.Net custom contract serialization and Collections(JSON.Net 自定义合约序列化和集合)
                    • <legend id='nGGkD'><style id='nGGkD'><dir id='nGGkD'><q id='nGGkD'></q></dir></style></legend>

                      <small id='nGGkD'></small><noframes id='nGGkD'>

                        <bdo id='nGGkD'></bdo><ul id='nGGkD'></ul>
                        • <i id='nGGkD'><tr id='nGGkD'><dt id='nGGkD'><q id='nGGkD'><span id='nGGkD'><b id='nGGkD'><form id='nGGkD'><ins id='nGGkD'></ins><ul id='nGGkD'></ul><sub id='nGGkD'></sub></form><legend id='nGGkD'></legend><bdo id='nGGkD'><pre id='nGGkD'><center id='nGGkD'></center></pre></bdo></b><th id='nGGkD'></th></span></q></dt></tr></i><div id='nGGkD'><tfoot id='nGGkD'></tfoot><dl id='nGGkD'><fieldset id='nGGkD'></fieldset></dl></div>

                            <tbody id='nGGkD'></tbody>
                            <tfoot id='nGGkD'></tfoot>