I have a perplexing issue with the System.io.Ports package in a Class Library I built using c#/.NET6.
I suspect it is a misconfiguration, but I'm not seeing much helpful documentation thus far on StackOverflow.
As some background, I must support an old ANSI C Windows application that collects data from a usb device.
To do so, we decided to create a c# component to do the job.
To test the component, I created three different test projects.
My first project simply created the component within a Console App. Everything worked as expected. Great!
My second example was to build a separate c#/Winforms Application that referenced the component. Again, worked as expected. More good news!
The problem occurred when we built a similar c++ Console Application to access the Component. We referenced the DLL, an had no issues instantiating the component; however, when the component tries to instantiate the SerialPort class, the PlatformNotSupported Exception is thrown:
"System.PlatformNotSupportedException System.IO.Ports is currently only supported on Windows "
I read in somewhere in a discussion group that this issue is that the default .netstandard dll is a cross platform DLL, and that the project should include the following addition.
<RuntimeIdentifier>win</RuntimeIdentifier>
No Luck with that mod for me, unfortunately.
Any ideas? The fundamental goal is to expose a few static methods to the ANSI C program.
It seems that the DLLExport NuGet isn't getting much love, which was my first choice.