Sunday 15 May 2011

UnauthorizedAccessException when trying to open a com port in C# -



UnauthorizedAccessException when trying to open a com port in C# -

i using arduino board write on serial com port, , using c# app read it. whenever seek run c# program, exception (unauthorizedaccessexception) occurs when tries open serial port. how open serial port?

i have little knowledge in c++. of knowledge comes similarities c++, , lot of googling tutorials. here 1 of codes copied 1 of tutorials found:

public partial class form1 : form { public form1() { initializecomponent(); } private void button2_click(object sender, eventargs e) { if(!serialport1.isopen) { serialport1.portname = "com3"; serialport1.open(); richtextbox1.text = "opened"; } } private void button1_click(object sender, eventargs e) { if(serialport1.isopen) { string text = richtextbox1.text; serialport1.writeline(text); } } }

c# serial-port

No comments:

Post a Comment