Problem with Serial Ports

Mar 13 2009 6:38 AM

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)