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

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?
ube100Asked:
Who is Participating?
 
DhaestConnect With a Mentor Commented:
Where do you get that error ?
Is the object moSearch initialized ?
0
 
ube100Author Commented:
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
 
ube100Author Commented:
As soon as I hit this line:

ResultCode leResultCode = moSearch.WebDedupeContact(ref lsErrorInfo, ref loIXMLDoc, lsFirstName + " " + lsLastName, "", "", "", "", "", "", Constants.IntelliSearch.MinimumMatchScore);
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
DhaestConnect With a Mentor Commented:
Check if one of your variables return null. I expect moSearch

(do you have somewhere in your code: YourType moSearch = new YourType())
0
 
ube100Author Commented:
yes,

moSearch has been initialized.
0
 
DhaestCommented:
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
 
ube100Author Commented:
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
All Courses

From novice to tech pro — start learning today.