I have a visual studio 2005 forms application that is giving me fits. I want to open a serial port in 1 form, set it to a com port in a class, then use it from that class. The problem is it gives my a null reference exception.
String^ comPort = "COM" + this->RS232CommPortNum->Value; int baudRate = Convert::ToInt32(this->cbBaudRate->Value); SerialPort^ com = gcnew SerialPort(comPort, baudRate); com->Open(); Rs232Handle->setRs232com(com);
This is where I try and set it.
in the .h and.....
System::Void Rs232::setRs232com(System::IO::Ports::SerialPort^ value)
Rs232com = value;
in the .cpp.
This does not work, it just raises in an exception. Does anyone know how to make this sort of thing work? Thanks.