using System;using System.Net;using System.Net.Sockets;using System.Threading;using System.IO.Ports;using Microsoft.SPOT;using Microsoft.SPOT.Hardware;using SecretLabs.NETMF.Hardware;using SecretLabs.NETMF.Hardware.Netduino;namespace barcode_scanner{ public class Program { public static InputPort bsr = new InputPort(Pins.GPIO_PIN_D0, false, Port.ResistorMode.Disabled); public static OutputPort led = new OutputPort(Pins.ONBOARD_LED, false); public static void Main() { // write your code here SerialPort mySerialPort = new SerialPort("COM1"); mySerialPort.BaudRate = 9600; mySerialPort.Open(); Thread.Sleep(Timeout.Infinite); mySerialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler); } public static void DataReceivedHandler( object sender, SerialDataReceivedEventArgs e) { led.Write(true); Thread.Sleep(1000); led.Write(false); } }}
i get An unhandled exception of type 'System.InvalidOperationException' occurred in Microsoft.SPOT.Hardware.SerialPort.dll upon following the above changes.