Skip to main content
Home Forums Silverlight Programming Visual Studio & Silverlight Development Tools your grampa's console window for Silverlight C#
6 replies. Latest Post by mrjvdveen on November 2, 2009.
(0)
dr d b k...
Member
62 points
119 Posts
10-28-2009 2:46 PM |
Dear Silverlighters;
Call me old fashioned, but can I launch the c# CLIENT code with a console window in VS2008 or VS2010 ?
I just want to get stubs in place as I figure out what do with with the various triggers and events the c# client will get from the xaml layer.
I know there is a way to launch a c++ main through a WinMain. Or I wasted a lot of time figguring it out.
If no console window, how about a nice logging control to put on a back panel to keep a log in a buffer on a control of some sort.
dr K (just old fashioned)
mrjvdveen
Participant
1953 points
369 Posts
10-29-2009 4:02 AM |
Against my better judgement, I'll try and subsitute your beloved console window with VS features.
For easy debugging output there is the Debug class. It has a static method called WriteLine, which outputs to the output window in VS.
If at some point you have a breakpoint and you need advanced stuff to be evaluated, you can use the immediate window. You can type stuff in C# in there and it will try to run it, without breaking your application.
HTH.
10-29-2009 7:17 PM |
Tell me more about the debug class.
I tried to use a textblock as a log, with scroll bars enabled (vertical and horizontal) but no joy (no bars).
Immediate window is immediately where ? On the client website debug or the output window in VS or what ?
Specifically, i'm looking for a quick and dirty way to log messages with low overhead.
Working on this tonight. I know you had to bite your fingers to respond to this.
What debug/hardcode logging options are there in Silverlight ?
I would love to make an semi-invisible/opaque/transparent textblock/logger. It would become visible on some error condition or just e-mail/SMS or tell mw. Or the user could type annotations in (or curses) when the users needs help.
dB
10-29-2009 7:19 PM |
where are the debug c# resources for silverlight ?
(i'm not a VS expert...)
10-30-2009 4:14 AM |
The Immediate Window is available through the menu Debug > Windows > Immediate or you can press Ctrl + D, I.
Ok, so everything you do with the Debug class is not there as soon as you build your software in Release mode, so it's great for debugging (what's in a name) but not for diagnostics in a production scenario. For that the Trace class, combined with TraceListeners would be much more helpful, however it's not available in SL3 (why not is beyond me).
However you could build some code to replicate the behavior. You need a static class that you can write to (supported by a singleton perhaps) and a class that receives the messages and displays them in some way. Give the static class a property to which you can assign the receiving class and each time a message is passed to the static class, check if the property is assigned an instance of the class and if so pass it the message.
The receiver class could simply output into a textbox (much better then a textblock for this scenario). You could attach the receiver class only when in some particular error state, keeping the load low whenever you're not in that state. Maybe you could add a button that allows the user to send the information to your email or something.
10-31-2009 8:19 PM |
how do I flush the TraceListner in C# ?
I switched to TextBox but don't get scroll bars.
11-02-2009 3:48 AM |
To flush your traces you call Trace.Flush();
Have you enabled scrolling on the TextBox? By default scrolling is turned off.