Skip to main content

Microsoft Silverlight

Answered Question your grampa's console window for Silverlight C#RSS Feed

(0)

dr d b karron
dr d b k...

Member

Member

62 points

119 Posts

your grampa's console window for Silverlight C#

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) 

 

dr d b karron
karron@casi.net
http://www.casi.net/
-----
I will mark your response as an answer after i test it. I have not forgotten your post !
------

mrjvdveen
mrjvdveen

Participant

Participant

1953 points

369 Posts

Re: your grampa's console window for Silverlight C#

 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.

-------------
Please mark a post as answer if it answers your question.
Visit my blog: http://jvdveen.blogspot.com

dr d b karron
dr d b k...

Member

Member

62 points

119 Posts

Re: your grampa's console window for Silverlight C#

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

dr d b karron
karron@casi.net
http://www.casi.net/
-----
I will mark your response as an answer after i test it. I have not forgotten your post !
------

dr d b karron
dr d b k...

Member

Member

62 points

119 Posts

Re: Re: your grampa's console window for Silverlight C#

where are the debug c# resources for silverlight ?

(i'm not a VS expert...)

dr d b karron
karron@casi.net
http://www.casi.net/
-----
I will mark your response as an answer after i test it. I have not forgotten your post !
------

mrjvdveen
mrjvdveen

Participant

Participant

1953 points

369 Posts

Answered Question

Re: your grampa's console window for Silverlight C#

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.

HTH.

-------------
Please mark a post as answer if it answers your question.
Visit my blog: http://jvdveen.blogspot.com

dr d b karron
dr d b k...

Member

Member

62 points

119 Posts

Re: Re: your grampa's console window for Silverlight C#

how do I flush the TraceListner in C# ?

I switched to TextBox but don't get scroll bars.

 

dr d b karron
karron@casi.net
http://www.casi.net/
-----
I will mark your response as an answer after i test it. I have not forgotten your post !
------

mrjvdveen
mrjvdveen

Participant

Participant

1953 points

369 Posts

Re: Re: your grampa's console window for Silverlight C#

 To flush your traces you call Trace.Flush();

Have you enabled scrolling on the TextBox? By default scrolling is turned off.

-------------
Please mark a post as answer if it answers your question.
Visit my blog: http://jvdveen.blogspot.com
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities