Fixing Codeplex issue 10912

This fixes a potential NullReferenceException; see https://fabtab.codeplex.com/workitem/10912