简体   繁体   English

Windows Phone编程Visual Studio

[英]Windows Phone Programming Visual Studio

I am programming some applications for the Windows Phone and am looking for some standard debugging practices that I cannot figure out how to do in a Windows Phone project in Visual Studio. 我正在为Windows Phone编写一些应用程序,并且正在寻找一些我无法弄清楚在Visual Studio的Windows Phone项目中如何做的标准调试实践。

  1. How can I print statements to the command line just for debugging purposes in a windows phone project? 如何在Windows Phone项目中仅出于调试目的将语句打印到命令行?
  2. Can I use MessageBox.show() (it seems that I cannot import System.Windows.Forms) 我可以使用MessageBox.show() (似乎无法导入System.Windows.Forms)

All help is appreciated! 感谢所有帮助!

you can use Debbugger.Log which will output to debug window 您可以使用Debbugger.Log它将输出到调试窗口

http://msdn.microsoft.com/en-in/library/system.diagnostics.debugger.log(v=vs.95).aspx http://msdn.microsoft.com/zh-CN/library/system.diagnostics.debugger.log(v=vs.95).aspx

Indeed, you cannot import System.Windows.Forms from a Windows Phone project. 的确,您不能从Windows Phone项目中导入System.Windows.Forms。 In the case of WP7 you will program using a subset of Silverlight. 对于WP7,您将使用Silverlight的子集进行编程。 With that in mind, there is a Message Box control in Silverlight for WP7 using the System.Windows namespace: http://msdn.microsoft.com/en-us/library/system.windows.messagebox(VS.95).aspx 考虑到这一点,在Silverlight中,使用System.Windows命名空间的WP7中有一个消息框控件: http : //msdn.microsoft.com/zh-cn/library/system.windows.messagebox(VS.95).aspx

I suggest that you approach your debugging needs by leveraging unit tests instead of printing to the Message Box. 我建议您通过利用单元测试而不是打印到消息框来满足调试需求。

For advanced tracing and logging you may want to take a look on 对于高级跟踪和日志记录,您可能需要看一下

Silverlight and WP7 Exception Handling and Logging building block Silverlight和WP7异常处理和日志构建基块

NLog for Windows Phone 适用于Windows Phone的NLog

  1. You can simply use Debug.WriteLine(Something); 您可以简单地使用Debug.WriteLine(Something); just like Console.WriteLine(Something); 就像Console.WriteLine(Something); . The Something will automatically be converted to string. Something将自动转换为字符串。 This is as simple as it can get. 这很简单。
  2. As indicated, you can indeed use MessageBox control. 如前所述,您确实可以使用MessageBox控件。 It's present in System.Windows namespace. 它存在于System.Windows命名空间中。 You can also use some third party toolkit like Coding4Fun if you need customized messagebox. 如果需要自定义的消息框,还可以使用某些第三方工具包,例如Coding4Fun。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM