【问题标题】:Windows Phone - Debug info lines cause the program to malfunctionWindows Phone - 调试信息行导致程序出现故障
【发布时间】:2014-02-18 09:35:19
【问题描述】:

您好,我正在开发一个 windows phone 应用程序,我正在使用

System.Diagnostics.Debug.WriteLine()

编写一些调试信息的功能,当我在手机连接到计算机和 Visual Studio 时以调试模式运行程序时没有问题。但是当我在没有调试器的情况下运行程序时——在每个发布和调试模式下安装时——这些调试信息行会导致应用程序遇到异常!

谁能解释一下里面发生了什么?

【问题讨论】:

  • 你得到什么异常?显示更多代码也会有所帮助。

标签: c# debugging windows-phone-8


【解决方案1】:

您可以尝试检查是否附加了调试器,然后仅在 IsAttached 值为 true 时执行特定于调试目的的代码:

if(System.Diagnostics.Debugger.IsAttached)
{
    System.Diagnostics.Debug.WriteLine();
}

【讨论】:

    猜你喜欢
    • 2021-02-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-29
    • 2020-01-28
    相关资源
    最近更新 更多