Open patrickmurray18 opened 1 year ago
Tagging subscribers to this area: @dotnet/area-system-io See info in area-owners.md if you want to be subscribed.
Author: | patrickmurray18 |
---|---|
Assignees: | - |
Labels: | `area-System.IO` |
Milestone: | - |
Correction to the above: FileStream.Read
actually fails in the same way. FileStream.ReadByte
works however.
It seems to be https://github.com/dotnet/runtime/issues/59754 which I thought we have fixed in https://github.com/dotnet/runtime/pull/59846.
@Jozkee could you PTAL? It looks like we are missing some error handling in
@Jozkee ping
Description
I am publishing a dotnet6 app from Windows and exporting to Linux (runtime=
ubuntu.16.04-x64
). At one point when my app tries to read from a device character file it fails (see below for exception).No other errors are encountered in the course of opening the file, querying the file etc. This appears to be due to the use of
BinaryReader
, just usingFileStream
doesn't fail like this.Reproduction Steps
Publishing this and running on Linux (mine is xfce) is sufficient to cause the exception.
Expected behavior
It should work as if calling
FileStream.Read
on the underlying file stream or at least give a more informative error ifBinaryReader
explicitly doesn't support special files.Actual behavior
Exception is thrown when the reproduction code is run:
Regression?
No response
Known Workarounds
Just using
FileStream
appears to be a workaround.Configuration
Publish command looks like this: dotnet publish /p:Configuration="Debug" /p:Platform="Any CPU" -r "ubuntu.16.04-x64" --self-contained
Development machine:
Runtime Environment: OS Name: Windows OS Version: 10.0.19044 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\6.0.305\
global.json file: Not found
Host: Version: 6.0.10 Architecture: x64 Commit: 5a400c212a
.NET SDKs installed: 2.1.524 [C:\Program Files\dotnet\sdk] 3.1.424 [C:\Program Files\dotnet\sdk] 6.0.301 [C:\Program Files\dotnet\sdk] 6.0.305 [C:\Program Files\dotnet\sdk]
.NET runtimes installed: Microsoft.AspNetCore.All 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.30 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Download .NET: https://aka.ms/dotnet-download
Learn about .NET Runtimes and SDKs: https://aka.ms/dotnet/runtimes-sdk-info
Other information
No response