EDN Admin
Well-known member
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri; font-size:small Hi
<p style="margin:0cm 0cm 10pt <span style="font-size:small <span style="font-family:Calibri I have been developed a simple web application to sending and receiving sms via a GSM modem connected to the serial port.
<span> But the problem is that it works fine just once and in the next trying to work with the modem I am facing the error âAccess denied to COM port COMXâ.
To work again with the modem I should manually unplugged and plugged it. I have been written the same code in a Win application and everything is okay.
<span>
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri; font-size:small I am using mCore .NET sms library 1.2 trial version to handle sending and receiving SMS.
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri; font-size:small I initialized the device with the
<span style="line-height:115%; font-family:Consolas; font-size:9.5pt SetCommParameters function<span style="font-family:Calibri; font-size:small as following:
<p style="line-height:normal; margin:0cm 0cm 0pt <span style="font-family:Consolas; color:blue; font-size:9.5pt private<span style="font-family:Consolas; font-size:9.5pt
<span style="color:blue void SetCommParameters()
<p style="line-height:normal; margin:0cm 0cm 0pt <span style="font-family:Consolas; font-size:9.5pt <span>
{
<p style="line-height:normal; margin:0cm 0cm 0pt 72pt <span style="font-family:Consolas; font-size:9.5pt <span>
objSMS.Port = <span style="color:#a31515 "COM6";
<p style="line-height:normal; margin:0cm 0cm 0pt <span style="font-family:Consolas; font-size:9.5pt <span>
<span> <span> <span> objSMS.BaudRate = (mCore.<span style="color:#2b91af BaudRate)(<span style="color:#2b91af Convert.ToInt32(<span style="color:#a31515 "9600"));
<p style="line-height:normal; margin:0cm 0cm 0pt <span style="font-family:Consolas; font-size:9.5pt <span>
objSMS.DataBits = (mCore.<span style="color:#2b91af DataBits)(<span style="color:#2b91af Convert.ToInt32(<span style="color:#a31515 "8"));
<p style="line-height:normal; margin:0cm 0cm 0pt <span style="font-family:Consolas; font-size:9.5pt <span>
objSMS.Parity = (mCore.<span style="color:#2b91af Parity)(0);
<p style="line-height:normal; margin:0cm 0cm 0pt <span style="font-family:Consolas; font-size:9.5pt <span>
objSMS.StopBits = (mCore.<span style="color:#2b91af StopBits)(1);
<p style="line-height:normal; margin:0cm 0cm 0pt <span style="font-family:Consolas; font-size:9.5pt <span>
objSMS.FlowControl = (mCore.<span style="color:#2b91af FlowControl)(0);
<p style="line-height:normal; margin:0cm 0cm 0pt <span style="font-family:Consolas; font-size:9.5pt <span>
}
<p style="line-height:normal; margin:0cm 0cm 0pt <span style="font-family:Consolas; font-size:9.5pt
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri; font-size:small To send a sms I am using the following code:
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri; font-size:small
<p style="line-height:normal; margin:0cm 0cm 0pt <span style="font-family:Consolas; font-size:9.5pt <span>
<span style="color:blue protected <span style="color:blue void Button_send_Click(<span style="color:blue object sender,
<span style="color:#2b91af EventArgs e)
<p style="line-height:normal; margin:0cm 0cm 0pt <span style="font-family:Consolas; font-size:9.5pt <span>
{
<p style="line-height:normal; margin:0cm 0cm 0pt <span style="font-family:Consolas; font-size:9.5pt <span>
SetCommParameters();
<p style="line-height:normal; margin:0cm 0cm 0pt <span style="font-family:Consolas; font-size:9.5pt <span>
<span style="color:blue string strSendResult = objSMS.SendSMS(TextBoxphone.Text,TextBoxBody.Text,
<span style="color:blue true);
<p style="line-height:normal; margin:0cm 0cm 0pt <span style="font-family:Consolas; font-size:9.5pt <span>
Label_Message.Text = <span style="color:#a31515 "Message sent!rnrn[Message Ref.: " + strSendResult +
<span style="color:#a31515 "]";
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri; font-size:small }
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri; font-size:small Pressing the send button works fine just for the first time and the sms will be sent. But pressing the button again will be caused the error âAccess denied to COM port
COM6â. It seems that the serial port left opened and to use it again it should be closed and reopened. So I close the port with the following code:
<p style="line-height:normal; margin:0cm 0cm 0pt <span style="font-family:Consolas; font-size:9.5pt <span>
objSMS.Disconnect();
<p style="line-height:normal; margin:0cm 0cm 0pt <span style="font-family:Consolas; font-size:9.5pt <span>
objSMS.Dispose();
<p style="line-height:normal; margin:0cm 0cm 0pt <span style="font-family:Consolas; font-size:9.5pt <span>
objSMS = <span style="color:blue null;
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri; font-size:small But the problem remains until the device unplugged and plugged manually. All above codes works fine in the windows application but it is not work in the ASP.NET web application.
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri; font-size:small I am really confused. Please help me to find the solution.
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri; font-size:small I am very thankful for helps
<br/>
View the full article
<p style="margin:0cm 0cm 10pt <span style="font-size:small <span style="font-family:Calibri I have been developed a simple web application to sending and receiving sms via a GSM modem connected to the serial port.
<span> But the problem is that it works fine just once and in the next trying to work with the modem I am facing the error âAccess denied to COM port COMXâ.
To work again with the modem I should manually unplugged and plugged it. I have been written the same code in a Win application and everything is okay.
<span>
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri; font-size:small I am using mCore .NET sms library 1.2 trial version to handle sending and receiving SMS.
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri; font-size:small I initialized the device with the
<span style="line-height:115%; font-family:Consolas; font-size:9.5pt SetCommParameters function<span style="font-family:Calibri; font-size:small as following:
<p style="line-height:normal; margin:0cm 0cm 0pt <span style="font-family:Consolas; color:blue; font-size:9.5pt private<span style="font-family:Consolas; font-size:9.5pt
<span style="color:blue void SetCommParameters()
<p style="line-height:normal; margin:0cm 0cm 0pt <span style="font-family:Consolas; font-size:9.5pt <span>
{
<p style="line-height:normal; margin:0cm 0cm 0pt 72pt <span style="font-family:Consolas; font-size:9.5pt <span>
objSMS.Port = <span style="color:#a31515 "COM6";
<p style="line-height:normal; margin:0cm 0cm 0pt <span style="font-family:Consolas; font-size:9.5pt <span>
<span> <span> <span> objSMS.BaudRate = (mCore.<span style="color:#2b91af BaudRate)(<span style="color:#2b91af Convert.ToInt32(<span style="color:#a31515 "9600"));
<p style="line-height:normal; margin:0cm 0cm 0pt <span style="font-family:Consolas; font-size:9.5pt <span>
objSMS.DataBits = (mCore.<span style="color:#2b91af DataBits)(<span style="color:#2b91af Convert.ToInt32(<span style="color:#a31515 "8"));
<p style="line-height:normal; margin:0cm 0cm 0pt <span style="font-family:Consolas; font-size:9.5pt <span>
objSMS.Parity = (mCore.<span style="color:#2b91af Parity)(0);
<p style="line-height:normal; margin:0cm 0cm 0pt <span style="font-family:Consolas; font-size:9.5pt <span>
objSMS.StopBits = (mCore.<span style="color:#2b91af StopBits)(1);
<p style="line-height:normal; margin:0cm 0cm 0pt <span style="font-family:Consolas; font-size:9.5pt <span>
objSMS.FlowControl = (mCore.<span style="color:#2b91af FlowControl)(0);
<p style="line-height:normal; margin:0cm 0cm 0pt <span style="font-family:Consolas; font-size:9.5pt <span>
}
<p style="line-height:normal; margin:0cm 0cm 0pt <span style="font-family:Consolas; font-size:9.5pt
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri; font-size:small To send a sms I am using the following code:
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri; font-size:small
<p style="line-height:normal; margin:0cm 0cm 0pt <span style="font-family:Consolas; font-size:9.5pt <span>
<span style="color:blue protected <span style="color:blue void Button_send_Click(<span style="color:blue object sender,
<span style="color:#2b91af EventArgs e)
<p style="line-height:normal; margin:0cm 0cm 0pt <span style="font-family:Consolas; font-size:9.5pt <span>
{
<p style="line-height:normal; margin:0cm 0cm 0pt <span style="font-family:Consolas; font-size:9.5pt <span>
SetCommParameters();
<p style="line-height:normal; margin:0cm 0cm 0pt <span style="font-family:Consolas; font-size:9.5pt <span>
<span style="color:blue string strSendResult = objSMS.SendSMS(TextBoxphone.Text,TextBoxBody.Text,
<span style="color:blue true);
<p style="line-height:normal; margin:0cm 0cm 0pt <span style="font-family:Consolas; font-size:9.5pt <span>
Label_Message.Text = <span style="color:#a31515 "Message sent!rnrn[Message Ref.: " + strSendResult +
<span style="color:#a31515 "]";
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri; font-size:small }
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri; font-size:small Pressing the send button works fine just for the first time and the sms will be sent. But pressing the button again will be caused the error âAccess denied to COM port
COM6â. It seems that the serial port left opened and to use it again it should be closed and reopened. So I close the port with the following code:
<p style="line-height:normal; margin:0cm 0cm 0pt <span style="font-family:Consolas; font-size:9.5pt <span>
objSMS.Disconnect();
<p style="line-height:normal; margin:0cm 0cm 0pt <span style="font-family:Consolas; font-size:9.5pt <span>
objSMS.Dispose();
<p style="line-height:normal; margin:0cm 0cm 0pt <span style="font-family:Consolas; font-size:9.5pt <span>
objSMS = <span style="color:blue null;
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri; font-size:small But the problem remains until the device unplugged and plugged manually. All above codes works fine in the windows application but it is not work in the ASP.NET web application.
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri; font-size:small I am really confused. Please help me to find the solution.
<p style="margin:0cm 0cm 10pt <span style="font-family:Calibri; font-size:small I am very thankful for helps
<br/>
View the full article