Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6692427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:51:59+00:00 2026-05-26T05:51:59+00:00

i keep getting this error message: Object reference not set to an instance of

  • 0

i keep getting this error message: Object reference not set to an instance of an object.

  private static void GetIPInfo(User user)
  {
      string ipAddress = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();

      string city = string.Empty;
      string region = string.Empty;
      string country = string.Empty;
      double? latitude = -1.00;
      double? longitude = -1.00;

      LocationTools.GetLocationFromIP(ipAddress, out city, out region, out country, out latitude, out longitude);

      user.IPAddress = user.IPAddress; **//error is pointing here**
  }

Do i need to instantiate something?

Would it be something like this to solve the problem?

 user.IPAddress new user.IPAddress = user.ipAddress;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:52:00+00:00Added an answer on May 26, 2026 at 5:52 am

    It depends on the way you are calling GetIPInfo(User user). It seems that you are passin null as user. Maybe you should write something like

    GetIPInfo(new User());
    

    But it is not clear whether User has to be initialized some way, or it is enough to create an empty instance.
    Furthermore, I do not understand what you are trying to do with user.IPAddress = user.IPAddress; It is an instruction that does not seem to have any effect at all, unless there is some other code in the setter of IPAddress which causes some collateral effect, but this is something I would avoid.

    EDIT after your comment:

    If I got it right (but I’m not really sure), maybe this is more similar to what you really need:

    private static User GetIPInfo()
    {
    User user = new User();

      string ipAddress = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();
    
      string city = string.Empty;
      string region = string.Empty;
      string country = string.Empty;
      double? latitude = -1.00;
      double? longitude = -1.00;
    
      LocationTools.GetLocationFromIP(ipAddress, out city, out region, out country, out latitude, out longitude);
    
      user.IPAddress = ipAddress; 
      // other code to fill the other fields of User
    
      return user;
    }
    

    Then you can call it and get a new instance of User that you can assign to a variable or use as you like.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I keep getting this error System.Web.HttpException was unhandled by user code Message=Validation of viewstate
I keep getting this error when I try to call Find() public void findTxt(string
I'm trying to compile a component using ant and keep getting this error message
I keep getting this error message when trying to write to the Event log
Following the RailsTutorial, I keep getting this error message (one of four actually) when
Following the RailsTutorial, I keep getting this error message (one of four actually) when
I keep getting this error in my windows logs: SharePointSocialNetworking.Facebook b0ceb144-b183-4b66-aa10-39fd9ee42bd4 Could not load
Additional information: Object reference not set to an instance of an object. I have
I keep getting this error message and I don't understand why: src\Parsing.hs:21:18: parse error
I'm trying to send emails from Joomla! 1.5.9, but keep getting this error message:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.