Please use the Code Sample
button to insert formatted code into your post. The code you posted isn't valid C# code and is hard to read as well.
Just a quick guess but GetValue("WindowsAuthentication")
would return null if there was no value. Hence you're dereferencing a null object and it crashes. To just fix this line of code you'd do something like this:
private bool isWindowAuthenticationInstalled ( RegistryKey registryKey )
{
var value = registryKey.GetValue("WindowsAuthentication")?.ToString() ?? "0";
return Int32.TryParse(value, out var result) ? result : false;
}