Object Reference error from IIS Componnet
One of c# windows application i am checking IIS components like windows authentication, Forms authentication etc installed or not. To Avoid object Reference error, if not installed components i am using below code
RegistryKey registryKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64).OpenSubKey(@"Software\Microsoft\InetStp\Components");
isFormsAuthenticationInstalled(registryKey )
private bool isFormsAuthenticationInstalled(RegistryKey registryKey)
{
string sRegistryValue = registryKey.GetValue(@"FormsAuthentication-1")?.ToString()??"0";
if (sRegistryValue == "1")
return true;
else
return false;
}
You can see i purposefully provided 'FormsAuthentication-1' To generate error in my local PC. but not getting Exception. But the same exe put in another system giving object reference error. Why?. New PC not installed IIS or visual studio