Re: Null-Reference Exception at loading CuteChat time

  •  02-21-2007, 2:47 AM

    Re: Null-Reference Exception at loading CuteChat time

     
    Hi
     
    I have found a workaround. I had to adapt the GetConnectionStringMethod.
     
    Old version:
     

    protected override string GetConnectionString( CuteSoft.Chat.UserIdentity user ){

       WindowsIdentity wi = HttpContext.Current.Session["Identity"] as WindowsIdentity;

       if ( wi != null ) {

          wi.Impersonate();

        }

        return ConfigurationSettings.AppSettings[ "DBConnectionString" ];

    }
     
     
     
     
    TO:
     

    protected override string GetConnectionString( CuteSoft.Chat.UserIdentity user ){

       WindowsIdentity wi = HttpContext.Current.Session["Identity"] as WindowsIdentity;

       if ( wi != null ) {

          wi.Impersonate();

        }else {

       throw new CuteChatException("No user identity available!");
       }

        return ConfigurationSettings.AppSettings[ "DBConnectionString" ];

    }
     
     
     
     
    If no user identity was available (this can happen during an iis reset as the session and forms authentication seem not to be perfectly sychnronised) no impersonation is done and database within the CuteChat dll will fail. If this happpens at loading time, somehow Cutehat gets into a state from which it cannot recover. This solution is now working for us. However, i still think this should not be possible. Access to a database might fail because of different reasons, such as network error, someone has played with the db settings etc.. I believe CuteChat could still fall into an irecovarable state, which should not be possible. I hope this is fixed in a future version (We never experienced this problem in version 3.1.0)
     
    Greetings
     
    Daniel 
View Complete Thread