By default, when creating a project, Visual Studio defines the Debug and Trace constants for the debug mode, and Trace only for the release mode.
I’ve set up a bare project which just outputs two logs, one with Trace and one with 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");
}
// [...]
}
}
Unfortunately, Visual Studio tells me that :
Error 3 The name 'Trace' does not exist in the current context C:\Dev\WP7\DebugTrace\DebugTrace\DebugTrace\App.xaml.cs 68 7 DebugTrace
Debug is working as expected.
I’ve searched a bit, and nobody seems to have this error. The project has been just created, I didn’t touch anything, and I don’t understand why Trace is not working although TRACE constant is defined.
I’m using Visual Studio 2010 express with a Windows Phone project.
I think Trace is not available for Window Phone 7. You might want to use some custom library for writing out Trace information through a WebService.
For example take a look at this and this
Trace in Windows Phone 7 won’t make much sense because you shouldn’t store that info on User’s phone. Instead you should pass it to a webservice which can write it out at a place where developer can get it