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

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

    • <bdo id='HbBpE'></bdo><ul id='HbBpE'></ul>
    1. <tfoot id='HbBpE'></tfoot>
    2. <legend id='HbBpE'><style id='HbBpE'><dir id='HbBpE'><q id='HbBpE'></q></dir></style></legend>

        c#终结器抛出异常?

        时间:2023-10-07
        <tfoot id='Sfl5k'></tfoot>
              <legend id='Sfl5k'><style id='Sfl5k'><dir id='Sfl5k'><q id='Sfl5k'></q></dir></style></legend>

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

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

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

                    <tbody id='Sfl5k'></tbody>
                1. 本文介绍了c#终结器抛出异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  引用自 MSDN:

                  如果 Finalize 或 Finalize 的覆盖引发异常,则运行时会忽略该异常,终止该 Finalize 方法,并继续终结过程.

                  If Finalize or an override of Finalize throws an exception, the runtime ignores the exception, terminates that Finalize method, and continues the finalization process.

                  如果我有:

                  ~Person()
                  {
                  throw new Exception("meh");
                  }
                  

                  那么它会导致运行时异常吗?

                  then it results in a runtime exception?

                  附言我知道这永远不会发生,但是我只是对这种行为感到好奇.我们的一个客户在他们所有的终结器周围都有一个空的 try catch.它甚至没有记录出现问题或重新定位对象:/

                  p.s. I know that this should never happen, however I'm just curious around this behaviour. One of our clients had an empty try catch around all of their finalizers.. it didn't even log when things went wrong or reserect the object :/

                  推荐答案

                  链接报价来源很重要.我不得不假设它谈论的是旧版本的 .NET,也许是 1.x 版.它试图容忍"未处理的异常,不吱声地吞下它们.效果并不好,大量代码静默失败非常难以调试.

                  Linking the source of your quote is important. I have to assume it talks about an old version of .NET, perhaps version 1.x. It tried to be "tolerant" of unhandled exceptions, swallowing them without a squeak. That did not work out well, chunks of code silently failing is extraordinarily hard to debug.

                  .NET 2.0 版本结束了这一点,默认 CLR 主机会因任何未处理的异常而终止应用程序.终结器中的异常是致命的.

                  The .NET 2.0 version put an end to that, the default CLR host terminates the app for any unhandled exception. An exception in a finalizer is fatal.

                  这篇关于c#终结器抛出异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:WPF 列表框动态填充 - 如何让它刷新? 下一篇:是否可以停止 .NET 垃圾收集?

                  相关文章

                2. <tfoot id='va4sZ'></tfoot>
                  1. <small id='va4sZ'></small><noframes id='va4sZ'>

                      <legend id='va4sZ'><style id='va4sZ'><dir id='va4sZ'><q id='va4sZ'></q></dir></style></legend>
                      • <bdo id='va4sZ'></bdo><ul id='va4sZ'></ul>

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