How to write to Visual Studio 2010 debug output window from Silverlight?
debugging, silverlight, visual-studio-2010
Solution
`System.Diagnostics.Debug.WriteLine` does indeed do what you're asking. I would check several things.
Make sure:
- You're attached to the right iexplore.exe process. Multiple iexplore.exe processes are launched, not just one.
- Your host project is set to debug Silverlight. This is an option in the project properties of the host project.
- If you set a breakpoint in your code that it does indeed break - if the code runs but the breakpoint isn't hit then you've attached using the wrong version of the code.
- "Show output from:" in the output window of visual studio is set to "Debug"
- If you right-click in the Output Window, ensure that "Program Output" is checked in addition to the other messages.
Problem
I am trying to get my Silverlight application to write to the Output/Debug window in Visual Studio 2010. I've tried `System.Diagnostics.Debug.WriteLine`, and `System.Diagnostics.Debugger.Log`, both of which seem to promise to write output to this window when the VS 2010 debugger is attached to the process. I attach VS 2010 to the iexplore.exe hosting the Silverlight app in Silverlight mode, but I have yet to see any of the output I am trying to log. I do see log messages for other things happening in the application; exceptions thrown, modules loaded, thread deaths, binding errors. What do I need to do in the Silverlight app to log to the same place? I guess my alternative is to log to a global StringBuilder and break the process in the debugger and examine that, but that is much less convenient than looking at the information as it is logged in real time.