xpnteam / xpnet

Develop X-Plane plugins in .NET.
MIT License
50 stars 15 forks source link

Exception when i use System.IO.Ports #27

Open allucche opened 4 years ago

allucche commented 4 years ago

Great development environment !! i have a problem with SerialPort class. I use serialport to communicate with Arduino Mega

NET CORE doesn't support this class so I used this: https://www.nuget.org/packages/System.IO.Ports/4.7.0

When execute plugin in Enable() i have: Inner Exception: PlatformNotSupportedException: System.IO.Ports is currently only supported on Windows. Stack: .........

is there any way to make it work? even just under WINDOWS Thank you!

jaurenq commented 4 years ago

Hi allucche,

I have successfully used that very package on Windows. The error you included there looks like you're not on Windows; see where it says "is currently only supported on Windows". What platform are you on?

jaurenq commented 4 years ago

@allucche , I dug out my old System.IO.Ports-using code and I now get the same error you're seeing. I did some Googling and it looks like MS may have actually just published a broken package.

https://github.com/dotnet/runtime/issues/25375

I worked around the problem by publishing the project and then digging down into runtimes\win\lib\netstandard2.0 and copying System.IO.Ports.dll and Microsoft.Win32.Registry.dll from there up to the root plugin directory, overwriting the copies of those two DLLs that were put there by the publish command. Have to redo that after every time running the publish command.

I also downgraded from System.IO.Ports 4.7 to 4.5, but I'm not sure if the downgrade was actually necessary to fix the problem.

Hopefully MS will fix their package.