Skip to content

Exception UnauthorizedAccessException

David Jensi

Asked Apr 2, 2015, 12:44 PM EDT1 answer
Share
LinkedInX
Please help, does not work.
 

  SerialPort serial = new SerialPort("COM4", 9600);
        Timer timer = new Timer();
        public Form1()
        {
            InitializeComponent();
            timer.Interval=5;
            timer.Tick += new EventHandler(aktivuj);


        }
        public void aktivuj(object sender,EventArgs e)
        {
            string s;
            Invalidate();
            serial.Open();
            serial.Write(textBox1.Text.ToString());
            s = serial.ReadLine();
            serial.Close();
            label1.Text = s;
        }


        

When I run the program occurs exception UnauthorizedAccessException.

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Afzaal Ahmad Zeeshan
    0
    Probably your application doesn't have enough permissions, such as using ports. Make sure you're not hiding these permissions anywhere. 
    0