Home All Groups Group Topic Archive Search About

Why Do I get this "Object reference not set to an instance of an object"

Author
15 Sep 2006 7:04 PM
sachdeva.rajesh
public string CreateAuthenticationToken(string strEncryptedUserName,
string strEncryptedPassword)
    {
        //Microsoft.Web.Services3.Security.Tokens.UsernameToken
userToken = new
Microsoft.Web.Services3.Security.Tokens.UsernameToken(strEncryptedUserName,
strEncryptedPassword, PasswordOption.SendHashed);
        UsernameToken objUserToken = new UsernameToken("admin",
"admin");
        Security security = null;

        try
        {
          *****************I am getting on this line, Don't why
            int strAuthToekn = security.Tokens.Add(objUserToken);
        }
        catch (Exception strException)
        {
            throw (strException);
            return strException.Message;
        }
    }

Author
15 Sep 2006 7:53 PM
ThunderMusic
you set security to null 1 line higher...  you can't call a property of
security if it's null...

I hope it helps

ThunderMusic

<sachdeva.raj***@gmail.com> wrote in message
Show quoteHide quote
news:1158347064.188486.185020@i42g2000cwa.googlegroups.com...
> public string CreateAuthenticationToken(string strEncryptedUserName,
> string strEncryptedPassword)
>    {
>        //Microsoft.Web.Services3.Security.Tokens.UsernameToken
> userToken = new
> Microsoft.Web.Services3.Security.Tokens.UsernameToken(strEncryptedUserName,
> strEncryptedPassword, PasswordOption.SendHashed);
>        UsernameToken objUserToken = new UsernameToken("admin",
> "admin");
>        Security security = null;
>
>        try
>        {
>          *****************I am getting on this line, Don't why
>            int strAuthToekn = security.Tokens.Add(objUserToken);
>        }
>        catch (Exception strException)
>        {
>            throw (strException);
>            return strException.Message;
>        }
>    }
>