2012-02-07 35 views

回答

3

用于登录到Visual Studio在运行,你可以使用Debug.Write

至于记录文件异常,WP7Contrib有一个异常日志记录库,作为NuGet上的WP7Contrib.Core的一部分可用。 WP7Contrib.Core的唯一依赖是Rx库。

编辑:您可以使用这样的WP7Contrib日志库:

private ILogManager logManager = new LoggingService(); 

private void Application_Launching(object sender, LaunchingEventArgs e) 
{ 
    logManager.Enable(); 
} 

private void Application_Activated(object sender, ActivatedEventArgs e) 
{ 
    logManager.Enable(); 
} 

private void Application_Deactivated(object sender, DeactivatedEventArgs e) 
{ 
    logManager.Disable(); 
} 

private void Application_Closing(object sender, ClosingEventArgs e) 
{ 
    logManager.Disable(); 
} 

编辑2:

说了这么多,我可能只使用一种推广方法:

// App.xaml.cs 
private ILogManager logManager = new LoggingService(); 

public App() 
{ 
    logManager.Attach(PhoneApplicationService.Current); 
} 

// LogManagerExtensions.cs 
public static class LogManagerExtensions 
{ 
    public static void Attach(this ILogManager logManager, PhoneApplicationService appService) 
    { 
     appService.Launching += (s,e) => logManager.Enable(); 
     appService.Activated += (s,e) => logManager.Enable(); 
     appService.Deactivated += (s,e) => logManager.Disable(); 
     appService.Closing += (s,e) => logManager.Disable(); 
    } 
} 
+0

好。谢谢你的回复理查德。关于WP7Contrib,我发现有一个WP7Contrib.Logging组件。但我找不到任何文件来描述如何使用它?你有什么想法吗? – 2012-02-07 07:30:53

+0

非常感谢您的工作!在App.xaml.cs中的 – 2012-02-07 08:13:32

+0

logManager.Attach参数不是macth – 2012-02-07 08:55:42

0

well.you可以尝试WP7Contrib开源项目在CodePlex [http://wp7contrib.codeplex.com/]并获取Windows手机应用程序中的例外日志记录。

如果你不想使用opensource Project,你可以自己定义Component。将异常记录存储为独立存储中的文件。

相关问题