Ruminations of J.net idle rants and ramblings of a code monkey

StreamInsight : What edition am I running?

Code Sample | StreamInsight

It is sometimes helpful to know what edition and/or version of StreamInsight you are using. This can be especially helpful as part of your application startup, where you can log this information for future/current troubleshooting. Unfortunately, there isn’t a good way to get that information from the StreamInsight API. Sure, you can use one of the Diagnostic Views – the scheduler diagnostic view – that will tell you how many schedulers are running, which will give you an idea of which edition you are running but it doesn’t provide things like the processor architecture installed (x86 vs. x64) nor will it tell you the exact edition of the instance. Oh … and that diagnostic view isn’t there in version 1.2. You’ll just know whether you are running Standard (1 scheduler) or one of Developer, DataCenter or Evaluation (1 scheduler / core). So here’s a little code snippet that will give you some more information:

/// <summary>
/// Gets information about the current StreamInsight service edition/// </summary>
/// <param name="instanceName">Name of the StreamInsight instance.</param>
/// <returns>String with edition information</returns>[System.Security.Permissions.RegistryPermission(
SecurityAction.Demand, Read="HKLM\\SOFTWARE\\Microsoft\\Microsoft StreamInsight")]
public string GetStreamInsightEditionInformation(string instanceName)
{
try{
var streamInsightRegistry = Microsoft.Win32.Registry.LocalMachine.OpenSubKey( @"SOFTWARE\Microsoft\Microsoft StreamInsight", false );var instanceKeyName = "MSSI." + instanceName;var instanceRegistryKey = streamInsightRegistry.OpenSubKey( instanceKeyName, false );StringBuilder sb = new StringBuilder();
sb.Append( "StreamInsight Version:" );
sb.AppendLine( instanceRegistryKey.GetValue( "Version" ).ToString() );
sb.Append( "Edition:" );
sb.AppendLine( instanceRegistryKey.GetValue( "Edition" ).ToString() );
sb.Append(  "Platform:" );
sb.AppendLine( instanceRegistryKey.GetValue( "PlatformId" ).ToString() );return sb.ToString();
}
catch{
return "Could not get StreamInsight information";
}
}

Some caveats: this will only work on the same machine where StreamInsight is running. So if you are connecting to StreamInsight remotely using the Management Service (for example, to a remote instance of the StreamInsight service), this won’t work for you. Also, it tells you the version of StreamInsight that the instance was installed with – which may not necessarily be the instance that you are running!!! For example, you can have a 1.0 instance, a 1.1 instance and a 1.2 instance. If you use Server.Create(“1.0 Instance”), you will actually be running StreamInsight 1.2! Fortunately, the Server object does have a Version property that will tell you which version you are running.