void TestProcessStartTime()
{
string startTimeString;
try
{
var p = global::System.Diagnostics.Process.GetCurrentProcess();
startTimeString = p.StartTime.ToString();
}
catch (Exception e)
{
startTimeString = e.ToString();
}
WriteLine($"StartTime: {startTimeString}");
}
android.runtime.JavaProxyThrowable: System.UnauthorizedAccessException: Access to the path '/proc/stat' is denied.
---> System.IO.IOException: Permission denied
--- End of inner exception stack trace ---
at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
at Interop.CheckIo(Error error, String path, Boolean isDirectory, Func`2 errorRewriter)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
at System.IO.Strategies.UnixFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
at System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
at System.IO.Strategies.FileStreamHelpers.ChooseStrategy(FileStream fileStream, String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, Int64 preallocationSize)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, Int64 preallocationSize)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
at System.IO.StreamReader.ValidateArgsAndOpenPath(String path, Encoding encoding, Int32 bufferSize)
at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks)
at System.IO.File.InternalReadAllText(String path, Encoding encoding)
at System.IO.File.ReadAllText(String path)
at System.Diagnostics.Process.get_BootTime()
at System.Diagnostics.Process.BootTimeToDateTime(TimeSpan timespanAfterBoot)
at System.Diagnostics.Process.get_StartTimeCore()
at System.Diagnostics.Process.get_StartTime()
Description
System.Diagnostics.Process.StartTimethrows an exception on net6.0-android, but works fine on Xamarin.AndroidReproduction Steps
https://github.com/BeyondDimension/AspNetCore.Mobile/blob/refs/tags/test-process-starttime/src/AspNetCore.Mobile.Droid/MainActivity.cs#L50-L63
Expected behavior
Returns the correct DateTime
Actual behavior
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
This is the compiled apk files
Xamarin.Android 12 APK
NET 6.0 APK