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 8487065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:07:43+00:00 2026-06-10T21:07:43+00:00

Ok so I totally new to C# and am trying to debug an error.

  • 0

Ok so I totally new to C# and am trying to debug an error. Basically I am trying to create an EventReceiver for a SharePoint List…this is the code that is giving me the object reference error when I am debugging:

   public override void ItemAdding(SPItemEventProperties properties)
   {
       base.ItemAdding(properties);

       SPListItem item = properties.ListItem;

       if (item["Name"] == null)
           return; //or better yet, log 

       string oldFileName = item["Name"].ToString();

What I am doing is entering Debug mode, and selecting to add a file to a SharePoint library (this is in ItemAdding event), now this error is shown after I select the file I want to upload, any idea why?

Thanks for any help!

  • 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-06-10T21:07:44+00:00Added an answer on June 10, 2026 at 9:07 pm

    It’s not an “object reference error”, it’s a NullReferenceException caused by the fact that you are trying access the index operator of item, which is null.

    You could have found this out by setting a breakpoint in the line of the if statement and hovering your mouse over the different variables.

    To fix this, make sure properties.ListItem contains a non-null value or insert another check in your if:

    if (item == null || item["Name"] == null)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im totally new when it comes to trying to make HTML code. I was
I'm totally new in C, and I'm trying to do a little application that
I am totally new to this and trying to host the simplest WCF service
Totally new to this! As the title says, I'm trying to serve a stream
I'm totally new to objective c and iphone development. I'm trying to create an
i am totally new to iphone and i am trying to create a universal
I'm totally new to android programming. I can see that this problem has been
Im totally new to WCF. Trying to create a Silverlight application with WCF services.
I am totally new to sharepoint and just trying to get something up and
I am totally new to Jasper report. While I am trying to follow this

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.