Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / August 2004

Tip: Looking for answers? Try searching our database.

Object reference not set to an instance of an object.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jason Kumpf - 27 Aug 2004 16:28 GMT
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!
Ignacio Machin \( .NET/ C#  MVP \) - 27 Aug 2004 20:53 GMT
Hi,

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

cheers,

Signature

Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

> I basically built a C# ASP.Net application on my local machine
> (running Windows XP, MSSQL2000, IIS) and it has been tested and ready
[quoted text clipped - 64 lines]
> Quarter is starting soon and we need this to work for our labs.
> Thanks!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.