Gergely on Silverlight

Determining Silverlight Version Installed

April 29th, 2010


The other day I wanted to find out what version of Silverlight is installed on my computer. This task is actually not as simple as it sounds as the Silverlight plugin is actually browser dependent: there’s a different one installed for Internet Explorer and a different for other browsers. The only way I’ve found to determine current Silverlight version is through Javascript.

Silverlight version detection: Internet Explorer

For Internet Explorer the ActiveXObject(“AgControl.AgControl”) has to be created. This object has and isVersionSupported(versionNumber) method which returns whether versionNumber is supported.

var AgControl = new ActiveXObject("AgControl.AgControl");
var version = "3.0.50106.0"; // The Silverlight version to test for
if(AgControl == null)
 alert("Silverlight is not installed!");
else if AgControl.isVersionSupported(version)
   alert("Silverlight v" + version + " is supported.");
else
   alert("Silverlight v" + version + " is not supported!");

Unfortunately it does not have a method that would return the current version thus to obtain the current version, version numbers have to be iterated. In my version detection script I’ve simply implemented a binary search that loops through the parts of the version numbers (major, minor, build and revision versions) determining the greatest version that is still supported. Not a very nice solution but the AgControl object leaves no other choice!

Silverlight version detection: other browsers (Firefox, Google Chrome, Safari etc)

For other browsers getting the Silverlight version is quite simple. The navigator.plugins["Silverlight Plug-In"] object contains information on the Silverlight plugin. It has the description member variable which contains the Silverlight version. This class makes version detection really simple compared to the hassle one has to go through with Internet Explorer!

var nav = navigator.plugins["Silverlight Plug-In"];
if(nav == null)
   alert("Silverlight is not installed!");
else
   alert("Silverlight version " + nav.description + " is installed.");

Silverlight version detection script

I have created a function that returns the current Silverlight version or -1 if Silverlight is not installed. This script is just a mixture of the Internet Explorer version detection part (with the binary version search implemented) and the other browsers detection script.

See this version detection script in action:

You can use the script the following way:

var slVersion = GetSilverlightVersion();
		if(slVersion != -1)
		   document.writeln("Your Silverlight version is: <strong>" +slVersion + "</strong>" );
		else
		   document.writeln("<strong>Your do not have Silverlight installed on this computer</strong>");

You can download the Javascript file here: SilverlightVersion.js, or download a standalone HTML version (where the script is embedded within the HTML) here: SilverlightVersion.html.

You can also simply copy the script source code from here:

Read the rest of this entry »

Thank you, volcano: Scott Logic office in the US

April 23rd, 2010

Last week I travelled to New York to attend the Kairos Global Summit. The event took part 16-18 April and I was planning on flying back 19 April. Due to the volcano eruption though, this departure never happened and my 4 day stay in the US suddenly grew to 11 days. After a mini New England tour this resulted in the opening of a temporary Scott Logic office in New Hampshire.

Hello, Wall Street

On the Kairos summit 500 selected students from top universities within the US, China, India, UK, Spain and Hungary had the chance to exhibit their projects and network with each others and of the many invited CEOs. The event itself was really good, the most unforgettable part being entering the New York Stock Exchange trading floor on Saturday where many of the projects were exhibited. It was nice to see some of our clients’ trading seats as I walked around. The trading floor itself was really impressive even with the stock market being closed with screens, phones and indexes everywhere.


On the NYSE trading floor (on the right)

Read the rest of this entry »

Ten Cool Things You Didn’t Know About Visual Studio 2010

April 8th, 2010

Late March I’ve attended the Guthalon in Glasgow – a talk by Scott Guthrie, Microsoft vice president. The topic was the new features of Visual Studio 2010, ASP.NET MVC 2 and Silverlight 4 and the Windows Phone 7. On this talk Scott showed some great new features in Visual Studio 2010. I’m sharing the ten most useful of these in this article.

1. Pin variables when debugging

At debugging when hovering over variables the “Pin variable” option appears. Clicking on this makes the variable stick next to the source code until removed (and the pin stays there between debugging sessions). It is a really hand utility eliminating having to add variables to the Watch window one by one or search through the Locals window to find the variable one’s looking for. Definitely one of the top 3 new features I use on a day to day basis!

2. Box selection

While holding down the Alt key box selection can be made on the screen. At first glance this feature doesn’t seem to useful. However when typing anything in the selection the same text appears in all lines. So this selection is extremely useful for mass renaming of e.g. visibilities or anything else that involves changing the same thing in all lines.

Read the rest of this entry »