gpt4 book ai didi

c# - 当前上下文中不存在名称 'trace'

转载 作者:行者123 更新时间:2023-11-30 17:14:21 25 4
gpt4 key购买 nike

默认情况下,在创建项目时,Visual Studio 为 Debug模式定义 Debug 和 Trace 常量,为 Release模式定义 Trace。

我建立了一个只输出两个日志的裸项目,一个带有 Trace,一个带有 Debug:

// etc.
using System.Diagnostics;

namespace DebugTrace
{
public partial class App : Application
{
// [...]

private void Application_Launching(object sender, LaunchingEventArgs e)
{
Debug.WriteLine("[Debug] Application launching");
Trace.WriteLine("[Release] Application launching");
}

// [...]
}
}

不幸的是,Visual Studio 告诉我:

Error   3   The name 'Trace' does not exist in the current context  C:\Dev\WP7\DebugTrace\DebugTrace\DebugTrace\App.xaml.cs 68  7   DebugTrace

调试按预期工作。

我搜索了一下,似乎没有人有这个错误。刚刚创建的项目,我什么都没动,虽然定义了TRACE常量,但我不明白为什么Trace不工作。

我在 Windows Phone 项目中使用 Visual Studio 2010 Express。

最佳答案

我认为 Trace 不适用于 Window Phone 7。您可能希望使用一些自定义库通过 WebService 写出 Trace 信息。

例如看看thisthis

Windows Phone 7 中的跟踪没有多大意义,因为您不应将该信息存储在用户的手机上。相反,您应该将它传递给一个 web 服务,该服务可以将它写在开发人员可以获得它的地方

关于c# - 当前上下文中不存在名称 'trace',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8833310/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com