How to write to Visual Studio 2010 debug output window from Silverlight?

I am trying to get a Silverlight application to write to an Output / Debug window in Visual Studio 2010.

I 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 am attaching VS 2010 to iexplore.exe, where the Silverlight application is hosted in Silverlight mode, but I still do not see any of the results that I am trying to execute. I see log messages for other things happening in the application; exceptions, loaded modules, death threads, binding errors. What do I need to do in a Silverlight application to enter the same location?

I assume that my alternative is to write to the global StringBuilder and interrupt the process in the debugger and check it, but this is much less convenient than viewing the information, since it is recorded in real time.

+4
source share
1 answer

System.Diagnostics.Debug.WriteLine really does what you ask. I would check a few things.

Make sure that:

  • You are tied to the correct iexplore.exe process. Several iexplore.exe processes are launched, and not just one.
  • Your host project is configured 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 really breaks - if the code works, but the breakpoint doesn’t hit, you are connected using the wrong version of the code.
  • "Show output from:" in the visual studio output window is set to "Debug"
  • If you right-click in the output window, make sure that "Program Output" is checked in addition to other messages.
+5
source

All Articles