I've been trying to create a C# Windows Forms Bluetooth serial application and then run it via Mono on my Raspberry Pi 3. I tried the following:
String SelectedDevice = AvailableDevicesComboBox.SelectedItem.ToString();
BSerialPort = new SerialPort(SelectedDevice, 115200, Parity.None, 8, StopBits.One);
BSerialPort.Open();
Using the standart System.IO.Ports library.
However I am not able to open the port, because I get the lovely exception "Object reference not set to an instance of an object", which means that there is no such port at all. I have paired the Bluetooth device to the RPi using one of the RFCOMM slots and then use it as serial (and have successfully transferred some strings via "cat" in the terminal), but the result in my app is the same, it actually doesn't show in the ComboBox. So I decided to use "32Feet-InTheHand" library for Bluez and Mono together. Bun now when I run my .exe file in Mono I get this in the Terminal:
Unhandled Exception: System.TypeLoadException:
Could not load type of field 'NameOfApp.Form1:BClient' (1) due to:
Could not load file or assembly 'InTheHand.Net.Personal,
Version=3.5.605.0, Culture=neutral, PublicKeyToken=ea38caa273134499'
or one of its dependencies. assembly:InTheHand.Net.Personal, Version=3.5.605.0,
Culture=neutral, PublicKeyToken=ea38caa273134499 type:<unknown type> member:<none>
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException:
Could not load type of field 'NameOfApp.Form1:BClient' (1) due to: Could not load file
or assembly 'InTheHand.Net.Personal, Version=3.5.605.0, Culture=neutral,
PublicKeyToken=ea38caa273134499' or one of its dependencies. assembly:InTheHand.Net.Personal,
Version=3.5.605.0, Culture=neutral, PublicKeyToken=ea38caa273134499
type:<unknown type> member:<none>
I have added the reference and marked it as required in the Application Files tab. But I'm not good at this at all...
Linux version: Raspbian 9 - Linux raspberrypi 4.9.59-v7+ #1047
Visual Studio Community 2017 version 15.5.3
Mono: Mono JIT compiler version 5.4.1.6
32Feet.NET: 3.5.605