-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting error on windows => System.PlatformNotSupportedException: 'System.IO.Ports is currently only supported on Windows.' #25375
Comments
@harvinders is it possible to boil this down to a minimal repro (would be at least two projects and stub sources) and share for us? I suspect a reference isn't flowing correctly through the project references. Meantime you may be able to work around this by adding a direct Nuget package reference from your app project to System.IO.Ports package. |
I believe the issue is within project.asset.json. I created a copy of the whole project and then removed stuff one by one. I removed the bin and obj and restored the packages. This resulted in a different project.asset.json. Unfortunately, I can't share it and still trying to have a meaningful minimal repo that reproduces the issue. Sorry about that. |
Same here, using 4.6.0 on nuget. Trying to decompile the System.IO.Ports.dll file (34 KB) copied to my app's directory revealed that it's actually a .NET Framework 4.7 assembly in which all methods in When dig into the nupkg, I can see the file So a faulty packing I guess? |
A slight bump: this issue persists in 4.7.0. |
Triage: @joperezr this appears to be packaging related, can you take a look? |
The package isn't correctly authored, my guess here is that the way that net461 project is consuming the package is via packages.config which won't produce an assets file so it's just bringing the same implementation picked by the netstandard assembly. It would really help if we could get a binlog to confirm my suspicions. Here is a way to work around it:
<PropertyGroup>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
<RuntimeIdentifier>win</RuntimeIdentifier>
</PropertyGroup>
After running the above steps, I'm getting the right System.IO.Ports placed in the binfolder and I'm able to run correctly. Please give that a try and if it doesn't work let me know so I can investigate. |
Maybe to add to this issue, we have a smiliar problem in our project and I tried to boil it down into this simple repo https://github.com/JonasGoldt/PortsPackageProblem The problem occurs with the library reference "Test"->"Library". When running the test, it loads the System.IO.Ports directly from the output folder, instead of the correct runtimes/win... version. The workaround mentioned by @danmosemsft works, but we have more complicated cases, e.g where we load unknown libs at runtime. For now, we copy the correct Ports assembly into the output folder ourselves. |
Still persists in v5 |
I switched my minimal repo (https://github.com/JonasGoldt/PortsPackageProblem) to .NET5 and System.IO.Ports 5.0.0 and it seems to be fixed. |
Sorry, forget my previous comment, it is still not working. I just made a mistake. I "fixed" my repo and switched to System.IO.Ports 5.0.1, the test still fails: |
Adding untriaged so the crew sees this update. |
I've stuck with this issue in my WPF project after migrating from .netframework to .NET 6. My library and main projects have TargetFramework as "net6.0-windows". Installing package System.IO.Ports 6.0.0 does not fix the issue. Only copying dll from runtime "net6.0" fixes it. For automation I added next code to the .csproj file:
|
I also have this problem since I migrated to .NET5 from .NET Framework 4x. |
I have a serialport project: |
@JanJorgensen |
@djanri |
Could anyone here facing the issue assist with the binlog @joperezr is asking for? |
This issue has been marked |
Here is my binlog. |
This issue has been automatically marked |
This issue will now be closed since it had been marked |
I have a .net standard 2.0 dll (Drivers.CommunicationLocal) which is referencing SerialPort class. When I try to use this from a .Net 4.6.1 console app or a xUnit (.net core 2.0) on windows 10, I get the following exception. Using it from UWP app works fine.
I am using nuget package
System.IO.Ports
.The text was updated successfully, but these errors were encountered: