About a week ago, i had the challenging task of detecting the installed version of Silverlight for all the users of a site that I’m building. We also wanted to log exactly which version of Silverlight that the user had installed, which at this point in time, enlists to about 6 useable versions:
- 2.0 RC0 (2.0.30523.9)
- 2.0 RTW (2.0.31005.0)
- 2.0 GDR (2.0.40115.0)
- 3.0 Beta (3.0.40307.0)
- 3.0 RTW (3.0.40625.0)
- 3.0 GDR (3.0.40723.0)
People who don’t use or have Windows update activated seems to have various versions of 2.0 installed… so the goal was to tell these people that they should upgrade to 3.0 RTW or GDR (either one is good).
The product/homepage is written in SL2.0, so all people who have SL2.0 and SL3.0 would see the page – but only the SL2.0 users should see the upgrade message !!
The Silverlight plugin however, does not have a built in ‘knowledge’ of what version is it! You can’t get the info inside Silverlight (which would be stupid anyway) but you CAN ask the plugin if a certain version is supported. The reason why it works like that, is because the on-page SL Instantiation has a property called MinimumVersion which holds a value like “2.0.30523.9” – a Javascript will then ask the installed plugin “Would this version of Silverlight work with you?” – of which it answers Yes or No… brilliant isn’t it ???
anyhoo… i found a script on House of Mirrors which detects the exact installed version of Silverlight! “Great” i thought for about 2 minutes… until i noticed that the script was in fact bruteforcing the version, by asking:
- is 2.0.0.0 supported ? ==> Yes
- is 3.0.0.0 supported ? ==> Yes
- is 4.0.0.0 supported ? ==> No
- is 3.1.0.0 supported ? ==> No
- etc…
in Chrome, this script took 15 seconds to detect the version !!!
so i upgraded the script with Binary search. And now it takes 50-500 msec (don’t know why it varies so much), much better i think :-)
here is the full script: SilverlightVersion.js
Try the old detection at House of mirrors: Slow SL Detection
Try the new : Fast SL Detection