邀请大峡一起来找茬,调用vc的dll,出现
未将对象引用设置到对象的实例错误....
[错误内容]
未处理的“System.NullReferenceException”类型的异常出现在 cmppAPI_test.exe 中。
其他信息: 未将对象引用设置到对象的实例
[部分代码]
[函数定义]
public class API_SubmitSMS
{
[DllImport( "LongSms.dll ",EntryPoint= "Cmpp_submitSMS ",SetLastError=true,CharSet=CharSet.Unicode,ExactSpelling=true,CallingConvention=CallingConvention.Cdecl)]
public static extern int Cmpp_submitSMS
(
StringBuilder SMId,//1
StringBuilder Registered_Delivery ,//2
StringBuilder Msg_level ,//3
byte[] Service_Id ,//4
StringBuilder Fee_UserType ,//5
byte[] Fee_terminal_Id ,//6
StringBuilder Fee_terminal_type,//7
StringBuilder TP_udhi,//8
StringBuilder Msg_Fmt ,//9
byte[] Msg_src ,//10
byte[] FeeType ,//11
byte[] FeeCode ,//12
byte[] ValId_Time ,//13
byte[] At_Time ,//14
byte[] Src_Id ,//15
StringBuilder DestUsr_tl ,//16
byte[] Dest_terminal_Id ,//17
StringBuilder Dest_terminal_type,//18
StringBuilder Msg_Length ,//19
byte[] Msg_Content ,//20
StringBuilder LinkID,//21
StringBuilder Msg_Id,//22
ulong Result//23
);
}
[调用]
//1
string s_SMID = " ";
//byte[] s1 = System.Text.Encoding.Unicode.GetBytes(s_SMID);
System.Text.StringBuilder s1 = new System.Text.StringBuilder(s_SMID);
//4 是否要求返回状态确认报告:0:不需要;1:需要;2:产生SMC话单(该类型短信仅供网关计费使用,不发送给目的终端)
string s_Registered_Delivery = " ";
//byte[] s2 = System.Text.Encoding.Unicode.GetBytes(s_Registered_Delivery);
System.Text.StringBuilder s2 = new System.Text.StringBuilder(s_Registered_Delivery);
//5 信息优先级别
string s_Msg_level = " ";
//byte[] s3 = System.Text.Encoding.Unicode.GetBytes(s_Msg_level);
System.Text.StringBuilder s3 = new System.Text.StringBuilder(s_Msg_level);
//6 业务类型,是数字、字母和符号的组合。
string s_Service_Id = " ";
byte[] s4 = System.Text.Encoding.Unicode.GetBytes(s_Service_Id);
//7 计费用户类型字段,0:对目的终端MSISDN计费;1:对源终端MSISDN计费;2:对SP计费;3:表示本字段无效,对谁计费参见Fee_terminal_Id字段。
string s_Fee_UserType = " ";
//byte[] s5 = System.Text.Encoding.Unicode.GetBytes(s_Fee_UserType);
System.Text.StringBuilder s5 = new System.Text.StringBuilder(s_Fee_UserType);
//8 被计费用户的号码(如本字节填空,则表示本字段无效,对谁计费参见Fee_UserType字段,本字段与Fee_UserType字段互斥)
string s_Fee_terminal_Id = " ";
byte[] s6 = System.Text.Encoding.Unicode.GetBytes(s_Fee_terminal_Id);
//9 GSM协议类型。详细是解释请参考GSM03.40中的9.2.3.9
string s_Fee_terminal_type = " ";
//byte[] s7 = System.Text.Encoding.Unicode.GetBytes(s_Fee_terminal_type);
System.Text.StringBuilder s7 = new System.Text.StringBuilder(s_Fee_terminal_type);
//10 G