3

如何在 ASP.NET 网站项目中定义 TRACE 编译标志?没有 .proj 文件,我可以在 Visual Studio 的任何构建对话框中找到任何选项。

我正在使用 Visual Studio 2008 和 ASP.NET 2.0。

4

1 回答 1

3

阅读这篇文章:

演练:将 ASP.NET 跟踪与 System.Diagnostics 跟踪集成

http://msdn.microsoft.com/en-us/library/b0ectfxd%28v=VS.80%29.aspx

查找子标题“启用跟踪自动编译您的应用程序”

你需要在你的 web.config 中加入这样的东西:

<system.codedom>
  <compilers>
    <compiler language="c#;cs;csharp" 
              extension=".cs" 
              compilerOptions="/d:TRACE"
              type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="1" />
    <compiler language="VB"
              extension=".vb" 
              compilerOptions="/d:Trace=true"
              type="Microsoft.VisualBasic.VBCodeProvider, System,                                        Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  </compilers>
</system.codedom>

这是 web.config 中编译器部分的文档,尽管它没有提到 Trace 的东西:

http://msdn.microsoft.com/en-us/library/y9x69bzw%28v=VS.80%29.aspx

我刚试过,它对我有用。

于 2011-08-17T22:09:11.977 回答