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

      <tfoot id='bM7QC'></tfoot>
    1. <small id='bM7QC'></small><noframes id='bM7QC'>

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

        如何将空引用分析的结果写入日志文件

        How to get result of Null Reference Analysis into a log file(如何将空引用分析的结果写入日志文件)
          • <bdo id='KTaYO'></bdo><ul id='KTaYO'></ul>
              <tbody id='KTaYO'></tbody>
          • <tfoot id='KTaYO'></tfoot><legend id='KTaYO'><style id='KTaYO'><dir id='KTaYO'><q id='KTaYO'></q></dir></style></legend>
            <i id='KTaYO'><tr id='KTaYO'><dt id='KTaYO'><q id='KTaYO'><span id='KTaYO'><b id='KTaYO'><form id='KTaYO'><ins id='KTaYO'></ins><ul id='KTaYO'></ul><sub id='KTaYO'></sub></form><legend id='KTaYO'></legend><bdo id='KTaYO'><pre id='KTaYO'><center id='KTaYO'></center></pre></bdo></b><th id='KTaYO'></th></span></q></dt></tr></i><div id='KTaYO'><tfoot id='KTaYO'></tfoot><dl id='KTaYO'><fieldset id='KTaYO'></fieldset></dl></div>

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

                1. 本文介绍了如何将空引用分析的结果写入日志文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我有以下课程.

                  class Tim
                  {
                      public Tim()
                      {
                  
                      }
                  
                      public Tom GetTom()
                      {
                          return new Tom();
                      }
                  
                  }
                  
                  class Tom
                  {
                      public Tom()
                      {
                  
                      }
                  
                      public Jim GetJim()
                      {
                          return new Jim();
                      }
                  }
                  
                  class Jim
                  {
                      public Jim()
                      {
                              
                      }
                  
                      public Jom GetJom()
                      {
                          return null;
                      }
                  }
                  
                  class Jom
                  {
                      public Jom()
                      {
                  
                      }
                  
                      public string GetMagicString()
                      {
                          return "Hello World";
                      }
                  }
                  

                  它的用法如下.

                  class Program
                  {
                      static void Main(string[] args)
                      {
                              new Tim().GetTom().GetJim().GetJom().GetMagicString();
                      }
                  }
                  

                  当我运行它时,会抛出空引用异常,新的空引用分析结果在新的异常帮助器中显示得很漂亮,如下所示.

                  When I run it, a Null Reference exception is thrown and new Null Reference Analysis results shows beautifully in the new Exception Helper as shown below.

                  这很好,因为它清楚地向我展示了这个链中的哪个方法调用导致了异常.但是,如果这段代码在现场运行,我也想在日志文件中记录这个错误.为此,当我在 catch 块中捕获 NullReferenceException 时,我没有得到有关返回 null 的方法的信息.这是否仅在 VS Exception Helper 对话框中可用并且此时无法记录?

                  This is great as it clearly shows me which method call in this chain is responsible for the exception. However, if this piece of code is running in field, I would also like to log this error in log file also. For that, when I capture the NullReferenceException in a catch block, I am not getting this info about the method that returned a null. Is this something only available in VS Exception Helper dialog only and cannot be logged at this point?

                  推荐答案

                  这是否仅在 VS Exception Helper 对话框中可用并且此时无法记录?

                  Is this something only available in VS Exception Helper dialog only and cannot be logged at this point?

                  是的,这仅在 Visual Studio 异常帮助程序中可用,此时无法记录.

                  Yes, this is something only available in the Visual Studio Exception Helper and cannot be logged at this point.

                  这并非不可能,但您必须使用与 Visual Studio 调试器等效的功能来检测您的代码.在正常的、非仪器化的场景中,没有关于 null 引用实际来自何处的记录,因此您的日志输出无法提供该信息.

                  It's not literally impossible, but you would have to instrument your code with the functional equivalent to the Visual Studio debugger. In a normal, non-instrumented scenario, there is no record of where the null reference actually came from, so no way for your logged output to provide that information.

                  这篇关于如何将空引用分析的结果写入日志文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 自定义合约序列化和集合)
                2. <legend id='5LhJI'><style id='5LhJI'><dir id='5LhJI'><q id='5LhJI'></q></dir></style></legend>

                    <tbody id='5LhJI'></tbody>

                  <small id='5LhJI'></small><noframes id='5LhJI'>

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

                          <bdo id='5LhJI'></bdo><ul id='5LhJI'></ul>