Try to alter your code to use Serial2.dll instead of SerialDevice.dll. Serial2 (or Agraham's SerialEx.dll) provide better functionallity and both are able to be combined with the .exe when compiled with Optimisation.
You also need to ensure (in the desktop IDE) that Serial2.dll (or SerialEx.dll
) are first referenced in 'Tools>Components' and your object added thereafter with 'Tools>Add Object'
If (when) you use Serial2.dll, you will need .Net CF 2.0 installed on your device.
One final note, there is a referrence to DBComm.dll having to be used with SerialDevice.dll - but I don't know much about it.
If you can load CF2.0 on your device, please use Serial2.dll