Re: Object reference not set to an instance of an object.

From: Ignacio Machin \( .NET/ C# MVP \) ("Ignacio)
Date: 08/27/04


Date: Fri, 27 Aug 2004 15:53:50 -0400

Hi,

 Check the configuration of your app, both in the web.config and in IIS and
make sure both are the same.

cheers,

-- 
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Jason Kumpf" <jknaty@yahoo.com> wrote in message
news:2d0278c.0408270728.1f55aaf4@posting.google.com...
> I basically built a C# ASP.Net application on my local machine
> (running Windows XP, MSSQL2000, IIS) and it has been tested and ready
> for deployment.  So I deploy it to our server (running Windows 2003
> Advanced Server, MSSQL 2000, IIS).  So I go to the site locally in
> case of an error (http://localhost/myApp/) and it works until a
> particular page.  All the .aspx.cs page does is call one of my classes
> but I get: "Object reference not set to an instance of an object." on
> the line where I am calling a method of that class.  This doesn't make
> sense to me as to why it works on my local machine and not the server
> as well as why that error, especially since the defailt.aspx.cs page
> calls that class and one of its methods.  Here are some snips of code
> to clarify.
>
> ================================================================
> // This is the section where the error occurs, the last statement is
> the line.
> IPrincipal person = HttpContext.Current.User;
> LATools.classes.LDAPUser ldUser = new LATools.classes.LDAPUser();
> string username = person.Identity.Name.ToString();
> string password = Session["ldapPassword"].ToString();
> string context = Session["ldapContext"].ToString();
> LdapConnection conn = ldUser.doConnect(
> username
> , password
> , context
> );
>
> // This is what IE shows
> Exception Details: System.NullReferenceException: Object reference not
> set to an instance of an object.
>
> Source Error:
> Line 63: IPrincipal person = HttpContext.Current.User;
> Line 64: LATools.classes.LDAPUser ldUser = new
> LATools.classes.LDAPUser();
> Line 65: LdapConnection conn = ldUser.doConnect(
> Line 66: person.Identity.Name.ToString()
> Line 67: , Session["ldapPassword"].ToString()
>
>
> // And just to maybe help more here is the method's code which uses
> the
> // Novell.Directory.Ldap class.
> public LdapConnection doConnect(string username, string password,
> string context)
> {
> string ldapHost = ConfigurationSettings.AppSettings["ldapServer"];
> int ldapPort =
System.Convert.ToInt32(ConfigurationSettings.AppSettings["ldapPort"]);
> LdapConnection conn = new LdapConnection();
> conn.Connect(ldapHost, ldapPort);
> string ldapDN = findUserDN(conn, username, context);
> if (conn.Connected == true)
> {
> try
> {
> conn.Bind(ldapDN, password);
> }
> catch (LdapException exp)
> {
> string sError = exp.LdapErrorMessage;
> return conn;
> }
> }
> return conn;
> }
>
> This is critical to our network and since I work for a University our
> Quarter is starting soon and we need this to work for our labs.
> Thanks!


Relevant Pages

  • Re: Problem with my Published web service
    ... UserValidation.UserExists(String UserName, String Domain, String strDC) --- ... When I deploy the service to my Local IIS, ... anyone have any idea what to check for so this web service will run via ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Re: Active Directory Authentication in IIS 6
    ... Dim obj As Object = entry.NativeObject. ... NMOWeb.FormsAuth.LdapAuthentication.IsAuthenticated(String domain, String ... need to keep it on 2000 with IIS 5.1 until we can figure it out. ... I generally recommend people just bind ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Active Directory Authentication in IIS 6
    ... Dim obj As Object = entry.NativeObject. ... String username, String pwd) ... need to keep it on 2000 with IIS 5.1 until we can figure it out. ... bind against the RootDSE object on the domain controller: ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Administrator rights issue with HTTP connectivity
    ... Dave - can you elaborate on item 2A - passing username a ... >1) You can run IIS and AS on the same machine, ... >string a domain username and pwd to impersonate on the ... >> I've defined a few permission groups to a cube. ...
    (microsoft.public.sqlserver.olap)
  • Re: Server.Transfer working for IIS 5.1 but not for IIS 6.0
    ... String from PageTransfer_Sender.aspx to PageTransfer_Target.aspx. ... private void btnTransfer_Click(object sender, System.EventArgs e) ... We have it working for IIS 5.0 but IIS 6.0 refusing ...
    (microsoft.public.dotnet.framework.aspnet)