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.
You can write run-time messages to the Output window using the Debug class or the Trace class, which are part of the System. Diagnostics class library. Use the Debug class if you only want output in the Debug version of your program. Use the Trace class if you want output in both the Debug and Release versions.
Right click on Silverlight project and select Debug tab from the project properties. Select "Out-of-browser application" radio button to enable Out of Browser debugging. Right click on Silverlight project and select "Set as Startup project". Once all configurations are completed run this application.
To see the debug output window, in Microsoft Visual Studio, click View, click Other Windows, and then click Output. You can view the debug output in this window only if the debugger is attached to the process that is writing to the output window.
System.Diagnostics.Debug.WriteLine
does indeed do what you're asking. I would check several things.
Make sure:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With