1
Answer

Problem with Serial Ports

henrik stridh

henrik stridh

15y
3.1k
1

Hello,

I´m having problem with get access to my Serial Ports using C#.  I’m using Visual Studio 2005 and Vista.

I’ve checked that the Serial Port is “COM1”, so this shouldn’t be the problem.

Error message: “System.UnauthorizedAccessException ”.

I’ve googled this and it seems to be some security problems, maybe with Vista.

The Code:

(using System.IO.Ports;)

public partial class Arduino : System.Web.UI.Page

{

    SerialPort sp = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One);

   

    protected void Page_Load(object sender, EventArgs e)

    {

       

    }

 

    protected void Button1_Click(object sender, EventArgs e)

    {

        sp.Open();

        TextBox1.Text = "" + sp.ReadByte();

        sp.Close();

    }

 

Anyone have experience from this?

Answers (1)