Solved

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

Posted on 2011-03-01
7
314 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
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

856 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