xpnet icon indicating copy to clipboard operation
xpnet copied to clipboard

Exception when i use System.IO.Ports

Open allucche opened this issue 5 years ago • 2 comments

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!

allucche avatar Feb 18 '20 11:02 allucche

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 avatar Feb 21 '20 03:02 jaurenq

@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.

jaurenq avatar Feb 27 '20 04:02 jaurenq