atom feed6 messages in com.googlegroups.dotnetdevelopmentRe: Access to the port 'COM9' is denied
FromSent OnAttachments
Nilantha EkanayakeMay 19, 2007 10:41 pm 
sriram reddyMay 20, 2007 5:19 am 
NilaMay 21, 2007 10:19 pm 
sriram reddyMay 22, 2007 3:51 am 
NilaMay 22, 2007 9:29 pm 
NilaMay 28, 2007 12:30 am 
Subject:Re: Access to the port 'COM9' is denied
From:sriram reddy (
Date:May 22, 2007 3:51:16 am


First of all did you try other COM ports. Why dont you try COM1 or 2 may be those works.

I didnt see any errors in the code and i compiled in my PC fine and reading my COM2 as i dont have COM9.

If you want to achive this much simple.

Dragh and drop the SerialPort controle from your Visual studio toolbox and set all properties as you want.

then to the code page of the win Form you instantiated the control and do some thing like this.

intializeComponenets() //this will be generated by your windows form designer


if (MyserialPort.Isopen) { // your event on data receive on Myserialport also you can use a timer object to tick every sec and grab the data from Port buffer //as GPS receiver puls one in every sec intervel

// then you read a line Myserialport.readline(); // GPS receiver place a line terminator after every pull by default // then log int your file or desplay the position on you co-ordinates


let em know if you need full code for receiving loging and displaying on given co-ordinates.


On May 22, 6:19 am, Nila <> wrote:

Hi.. It was a windows project.I found it from code project --codings are #region Namespace Inclusions using System; using System.IO.Ports; using System.Windows.Forms; #endregion

namespace PortProgramming { class SerialPortProgram { // Create the serial port with basic settings private SerialPort port = new SerialPort("COM9", 9600, Parity.None, 8, StopBits.One);

[STAThread] static void Main(string[] args) { // Instatiate this class new SerialPortProgram(); }

private SerialPortProgram() { Console.WriteLine("Incoming Data:");

// Attach a method to be called when there is data waiting in the port's buffer port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);

// Begin communications port.Open();

// Enter an application loop which keeps this thread alive Application.Run(); }

private void port_DataReceived(object sender, SerialDataReceivedEventArgs e) { // Show all the incoming data in the port's buffer Console.WriteLine(port.ReadExisting()); } }


On May 20, 5:19 pm, sriram reddy <> wrote:


DId yo do he project as webproject or windows project? looks like your trying to access serial port from IIS if so try to impersonalize the access.


On May 20, 6:41 am, "Nilantha Ekanayake" <> wrote:

i have tryed to connect to gps reserver with using but i got an error.i have full permission to my pc.i disable firewall also.please help me to solove this problem

System.UnauthorizedAccessException was unhandled Message="Access to the port 'COM9' is denied." Source="System" StackTrace: at System.IO.Ports.InternalResources.WinIOError(Int32 errorCode, String str) at System.IO.Ports.SerialStream..ctor(String portName, Int32 baudRate, Parity parity, Int32 dataBits, StopBits stopBits, Int32 readTimeout, Int32 writeTimeout, Handshake handshake, Boolean dtrEnable, Boolean rtsEnable, Boolean discardNull, Byte parityReplace) at System.IO.Ports.SerialPort.Open() at PortProgramming.SerialPortProgram..ctor() in E:\CJ's Documents\4thYear\Project\Temp\PortProgramming\PortProgramming\Program.cs:l­­ine 31 at PortProgramming.SerialPortProgram.Main(String[] args) in E:\CJ's Documents\4thYear\Project\Temp\PortProgramming\PortProgramming\Program.cs:l­­ine 20 at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

at System.Threading.ThreadHelper.ThreadStart()- Hide quoted text -

- Show quoted text -