hello,
I am a student and I am trying to build an application to send SMS. For that I have to modify this source code at code project article
http://www.codeproject.com/KB/cs/SMS.aspx?msg=3533311#xx3533311xx

SmsSubmitPdu pdu;
pdu = new SmsSubmitPdu(richTextBox1.Text, textBox1.Text, "");
GsmCommMain comm = new GsmCommMain();
CommSetting.comm.SendMessage(pdu);


I have used this code to send sms, but I got the following error

Object reference not set to Instance of an object

please try to answer, at least what this error means

The error "Object reference not set to Instance of an object" tends to be a common one I've seen.

Basically it's telling you that you're trying to use an object (read: class) that hasn't been instantiated yet, or rather, that hasn't been instantiated in the way you think it has :twisted:

For example:

  • I create a class called LoginDetails which will contain my connection strings and such that I can call with various methods inside the class
  • In my program I use "string connString = LoginDetails.connStr" to try to call my connection string

The IDE understands that I'm calling connStr from class LoginDetails as they share the same namespace but...I haven't created an instance of LoginDetails and I cannot call directly from an uninstantiated class so I would get an error similar to what you got.

If I change the details a bit and do this instead:

  • I create a class called LoginDetails which will contain my connection strings and such that I can call with various methods inside the class
  • In my program I create an instance of LoginDetails by using "LoginDetails lDet = new LoginDetails()"
  • In my program I use "string connString = lDet.connStr" to try to call my connection string

In this way I eliminate the error.

There are many ways you can be getting the error you mentioned but all derive from an object or class not being properly instantiated prior to an attempt to call properties or methods of that object or class.

Hope this helps :) Please remember to mark as solved once your issue is resolved.

This article has been dead for over six months. Start a new discussion instead.