Broken if statement
- by Vladimir Nani
Maybe I am crazy but how that could be? some == null is always false but debugger goes into if-statement body anyway. Any ideas?
I have restarted visual studio
I have cleaned every bin/obj folder
It is not the case that i don`t understand that WindowsIdentity.GetCurrent() may return null. That was my first idea.
var some = new object();
if (some == null) {
throw new Exception("hi!");
}
else {
do();
}
My code:
private void GetCurrentWindowsIdentity() {
var identity = WindowsIdentity.GetCurrent()
if (identity == null) {
throw new Exception(Errors.IdentityIsNullException);
}
try {
if (CurrentAuthenticationWrapper.AuthenticationType ==
AuthenticationType.Windows) {
CurrentLogin = _identity != null ? _identity.Name : string.Empty;
}
} catch (Exception ex) {
ViewManager.ShowError(ex);
}
_identity = identity;
}