Solved

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

Posted on 2011-03-01
7
302 Views
Last Modified: 2012-05-11
Hi,

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);
        [DispId(1610809829)]

And on the top of interface where we got this declaration also have these attribute as well for the interface:
 [Guid("903FB89C-F136-418D-A72D-0B917B1748BB")]
    [TypeLibType(4304)]

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

Accepted Solution

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

Author Comment

by:ube100
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.
0
 

Author Comment

by:ube100
ID: 35007993
As soon as I hit this line:

ResultCode leResultCode = moSearch.WebDedupeContact(ref lsErrorInfo, ref loIXMLDoc, lsFirstName + " " + lsLastName, "", "", "", "", "", "", Constants.IntelliSearch.MinimumMatchScore);
0
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

by:Dhaest
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())
0
 

Author Comment

by:ube100
ID: 35008116
yes,

moSearch has been initialized.
0
 
LVL 53

Expert Comment

by:Dhaest
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)
0
 

Author Comment

by:ube100
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
        {
            get
            {
                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?
0

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 (http://www.enterprise.efax.com), 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