Page 1 of 1

Exception - object reference not set to an instance of an ob

Posted: Mon May 23, 2011 7:50 am
by CSCdev
Dear Sir,
I have the below code for submitting SMS messages to the SMPP server, occasionally an exception is raised:
"object reference not set to an instance of an object"
can you please advise on what could be the problem and how to take care of it?

Thank you

Code: Select all

	 
 List<Inetlab.SMPP.PDU.SubmitSm> req = client.PrepareSubmit(
                   Inetlab.SMPP.Common.SubmitMode.ShortMessage,
                   Convert.ToByte(5),
                   Convert.ToByte(1),
                   SMS.sms_SenderID,
                   Convert.ToByte(1),
                   Convert.ToByte(1),
                   SMS.sms_MobileNo,
                   smsEncoding,
                   SMS.sms_Text);
               
                   foreach (Inetlab.SMPP.PDU.SubmitSm sm in req)
                   {
                        sm.ValidityPeriod = DateTime.Now.AddDays(2).ToString("yyMMddhhmmss000+");
                   }
try
                   {
                       List<Inetlab.SMPP.PDU.SubmitSmResp> resp = client.Submit(req);
                       if (resp.Count > 0)
                       {
                           if (resp[0].Status == Inetlab.SMPP.Common.CommandStatus.ESME_ROK)
                               sms_RESP = "ACK#" + resp[0].MessageId;
                           else
                               sms_RESP = "NAK#" + resp[0].Status.ToString();
                       }
                       else
                       {
                           sms_RESP = "NAK#NO RESP RECEIVED";
                       }
                   }
                   catch (Exception ex)
                   {
                       MessageBox.Show(ex.Message);
                   }

Re: Exception - object reference not set to an instance of a

Posted: Mon May 23, 2011 8:56 pm
by alt
Could you post exception stack trace?

Re: Exception - object reference not set to an instance of a

Posted: Tue May 24, 2011 1:59 pm
by CSCdev
20110524 16:48:30 :SMS_Send
20110524 16:48:30 :Object reference not set to an instance of an object.
------------------------------------------------
20110524 16:48:30 :SMS_Send
20110524 16:48:30 : at Inetlab.SMPP.SmppClient.VqEl9oC9Po6YdHt4Qla(Object )
at Inetlab.SMPP.SmppClient.Submit(SubmitSm data)
at Inetlab.SMPP.SmppClient.Submit(List`1 submit_sm_list)
at CSC_SMS_Sender.frmMain.SMS_Send(SMS_INFO SMS)
------------------------------------------------

Re: Exception - object reference not set to an instance of a

Posted: Tue May 31, 2011 9:05 am
by alt
Sorry, but I cannot reproduce this error.
Could you try with last version 1.0.10.1 and post here StackTrace again if you get similar exception.