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

Posted on 2011-03-01
Last Modified: 2012-05-11

This following C# code snippet throwing an error when I execute in my program.

 ResultCode leResultCode = moSearch.WebDedupeContact(ref lsErrorInfo, ref loIXMLDoc, lsFirstName + " " + lsLastName, "", "", "", "", "", "", Constants.IntelliSearch.MinimumMatchScore);

The error is: Object reference not set to an instance of an object...

I have view the definition for the class ResultCode as shwon below:

ResultCode WebDedupeContact(ref string ErrorInfo, ref IXMLDOMDocument2 XMLDoc, string SlxContact, string SlxAccountID, string Address, string City, string State, string Postcode, string Country, short MinimumMatchScore);

And on the top of interface where we got this declaration also have these attribute as well for the interface:

What are these mean? and most importantly where could this error be generated from?
Question by:ube100
  • 4
  • 3
LVL 53

Accepted Solution

Dhaest earned 250 total points
ID: 35007972
Where do you get that error ?
Is the object moSearch initialized ?

Author Comment

ID: 35007978
Sorry Just a small correction:

ResultCode is not a class it is a enum class and that definition is for WebDedupeContact which was defined in a interfcace.

Author Comment

ID: 35007993
As soon as I hit this line:

ResultCode leResultCode = moSearch.WebDedupeContact(ref lsErrorInfo, ref loIXMLDoc, lsFirstName + " " + lsLastName, "", "", "", "", "", "", Constants.IntelliSearch.MinimumMatchScore);
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

LVL 53

Assisted Solution

Dhaest earned 250 total points
ID: 35008044
Check if one of your variables return null. I expect moSearch

(do you have somewhere in your code: YourType moSearch = new YourType())

Author Comment

ID: 35008116

moSearch has been initialized.
LVL 53

Expert Comment

ID: 35008138
Check all the other variables, fe ref lsErrorInfo, ref loIXMLDoc

Do you have that functions also in debug (perhaps there is an issue in that function)

Author Comment

ID: 35008280
I have check the moSearch and that is null when we executing it so what should look for?

 private iSearchSLX moSearch

public iSearchSLX Search
                return moSearch;
This is how it's been created. This code is perfectly working code but I'm investigating something at the moment and propbably it is not creating the object under the condition I'm working? How do I find out about what causing it to not to create that object? Something to with Singleton pattern?

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now