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

.NET library for SMPP protocol
Locked
CSCdev
Posts: 2
Joined: Thu May 12, 2011 7:34 am

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

Post by CSCdev » Mon May 23, 2011 7:50 am

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);
                   }
alt
Site Admin
Posts: 985
Joined: Tue Apr 25, 2006 9:45 am

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

Post by alt » Mon May 23, 2011 8:56 pm

Could you post exception stack trace?
CSCdev
Posts: 2
Joined: Thu May 12, 2011 7:34 am

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

Post by CSCdev » Tue May 24, 2011 1:59 pm

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)
------------------------------------------------
alt
Site Admin
Posts: 985
Joined: Tue Apr 25, 2006 9:45 am

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

Post by alt » Tue May 31, 2011 9:05 am

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.
Locked