Saturday, August 7, 2010

PowerFlasher SOS Max Logging for Silverlight...

If you are not familiar with SOS Max, it's a socket output server that is used to display logging messages sent via a client application for debugging. The beauty behind this concept is that it supports any language with socket support, and since SOS Max is written in Java, it's cross platform. At Electrotank, we use it for most all our client side projects in AS3. To do this, we use an SOSLogTarget class written by Sönke Rohde. You  can find more information for the AS3 version at:

http://soenkerohde.com/2008/08/sos-logging-target/

I was piddling around on Twitter this morning and saw that Jobe Makar had tweeted that he was going to have a go at Silverlight. The next few tweets were his remarks on some annoying issues with simply logging output to the Console in Firefox (which, off-topic, he found the solution here: http://bit.ly/9YpZF7 in the bottom post). His issues oddly inspired me to check out Silverlight myself, as I have some experience with C# and XNA, so it was coming one way or another -- why not today?

Immediately, I noted that Jobe's problem was, in fact, just as annoying as he said. So, to solve this issue on a larger scale, I wrote a very basic SOS Max logging target that works with the Silverlight C# API. The full source (with an example) can be found here:

http://github.com/mbolt35/OpenSource/raw/master/blogspot/silverlight/Bolt/CSharp/SOSLog.cs

However, because Silverlight has some pretty annoying security policies when it comes to sockets, you have to run the Silverlight application "Out of Browser." To do this:
  • In the Solution Explorer, right-click your application and select Properties.
  • Select the Silverlight tab and check the option that says "Enable running application out of the browser"

  • Then click the now enabled "Out-of-Browser Settings..." button.
  • Check the option that says "Require elevated trust when running outside the browser."
 
  • Press "OK"
    Now you should be all set to go... 



    Hope you find this useful - The source is written under the Apache License, so you can feel free to use it how you want. 

    Matt Bolt
    Post a Comment