Repository navigation
Closed
Description
I think this might be back. I've had to disable auto tracking to avoid a crash. I thought a try catch would work, but doesn't:
System.IO.FileNotFoundException thrown
at Interop.ThrowExceptionForIoErrno(Interop.ErrorInfo errorInfo, string path, bool isDirError) in System.Private.CoreLib.dll
at Interop.CheckIo(Interop.Error error, string path, bool isDirError) in System.Private.CoreLib.dll
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(string path, Interop.Sys.OpenFlags flags, int mode, bool failForSymlink, out bool wasSymlink, Func<Interop.ErrorInfo, Interop.Sys.OpenFlags, string, Exception> createOpenException) in System.Private.CoreLib.dll
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(string fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, long preallocationSize, UnixFileMode openPermissions, out long fileLength, out UnixFileMode filePermissions, bool failForSymlink, out bool wasSymlink, Func<Interop.ErrorInfo, Interop.Sys.OpenFlags, string, Exception> createOpenException) in System.Private.CoreLib.dll
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(string fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, long preallocationSize, UnixFileMode? unixCreateMode, Func<Interop.ErrorInfo, Interop.Sys.OpenFlags, string, Exception> createOpenException) in System.Private.CoreLib.dll
at System.IO.Strategies.OSFileStreamStrategy..ctor(string path, FileMode mode, FileAccess access, FileShare share, FileOptions options, long preallocationSize, UnixFileMode? unixCreateMode) in System.Private.CoreLib.dll
at System.IO.Strategies.UnixFileStreamStrategy..ctor(string path, FileMode mode, FileAccess access, FileShare share, FileOptions options, long preallocationSize, UnixFileMode? unixCreateMode) in System.Private.CoreLib.dll
at System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(string path, FileMode mode, FileAccess access, FileShare share, FileOptions options, long preallocationSize, UnixFileMode? unixCreateMode) in System.Private.CoreLib.dll
at System.IO.Strategies.FileStreamHelpers.ChooseStrategy(FileStream fileStream, string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options, long preallocationSize, UnixFileMode? unixCreateMode) in System.Private.CoreLib.dll
at System.IO.FileStream..ctor(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options, long preallocationSize) in System.Private.CoreLib.dll
at System.IO.FileStream..ctor(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options) in System.Private.CoreLib.dll
at System.IO.FileStream..ctor(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, bool useAsync) in System.Private.CoreLib.dll
at System.IO.FileStream..ctor(string path, FileMode mode, FileAccess access, FileShare share) in System.Private.CoreLib.dll
at System.IO.File.OpenRead(string path) in System.Private.CoreLib.dll
at Sentry.Internal.FileSystemBase.OpenFileForReading(string path) in Sentry.dll
at Sentry.Internal.Json.Load<PersistedSessionUpdate>(IFileSystem fileSystem, string filePath, Func<JsonElement, PersistedSessionUpdate> factory) in Sentry.dll
at Sentry.GlobalSessionManager.<.ctor>b__11_0(string filePath) in Sentry.dll
at Sentry.GlobalSessionManager.TryRecoverPersistedSession() in Sentry.dll
at Sentry.Internal.Hub.StartSession() in Sentry.dll
at Sentry.Integrations.AutoSessionTrackingIntegration.Register(IHub hub, SentryOptions options) in Sentry.dll
at Sentry.Internal.Hub..ctor(SentryOptions options, ISentryClient client, ISessionManager sessionManager, ISystemClock clock, IInternalScopeManager scopeManager, RandomValuesFactory randomValuesFactory, IReplaySession replaySession, ISampleRandHelper sampleRandHelper, BackpressureMonitor backpressureMonitor) in Sentry.dll
at Sentry.SentrySdk.InitHub(SentryOptions options) in Sentry.dll
at Sentry.SentrySdk.Init(SentryOptions options) in Sentry.dll
at Sentry.Maui.Internal.SentryMauiInitializer.Initialize(IServiceProvider services) in Sentry.Maui.dll
at Microsoft.Maui.MauiContextExtensions.InitializeAppServices(MauiApp mauiApp) in //src/Core/src/MauiContextExtensions.cs:line 83
at Microsoft.Maui.Hosting.MauiAppBuilder.Build() in //src/Core/src/Hosting/MauiAppBuilder.cs:line 198
at CodeLogicMaster.MauiProgram.CreateMauiApp() in D:\AppsInStores\Maui\CodeLogicMaster\CodeLogicMaster\MauiProgram.cs:line 131
at CodeLogicMaster.Platforms.Android.MainApplication.CreateMauiApp() in D:\AppsInStores\Maui\CodeLogicMaster\CodeLogicMaster\Platforms\Android\MainApplication.cs:line 14
at Microsoft.Maui.MauiApplication.OnCreate() in /_/src/Core/src/Platform/Android/MauiApplication.cs:line 36
at Android.App.Application.n_OnCreate(nint jnienv, nint native__this) in Mono.Android.dll
Originally posted by @BillyMartin1964 in #3653
Note
The stack trace clearly indicates a try..catch block isn't catching this exception. Apparently the when is an exception filter, that requires some special treatment in the runtime so there could be bugs around that. However we'd need a repro in order for Microsoft to be able to look into this further. If anyone is able to reliably reproduce this issue on Android, please let us know.
Metadata
Metadata
Assignees
Projects
- StatusShow more project fieldsWaiting for: Product Owner
Activity
linear-code commentedon Mar 29, 2026
NET-633
[-]Possible regression: Failed to persist session on the file system. #3653[/-][+]Possible regression: Failed to persist session on the file system[/+]jamescrosswell commentedon Mar 29, 2026
It is unusual that the
try..catchblock isn't working:sentry-dotnet/src/Sentry/GlobalSessionManager.cs
Lines 198 to 203 in ed60599
However it looks like we could work around this easily enough simply by checking whether the file exists before trying to read it:
sentry-dotnet/src/Sentry/GlobalSessionManager.cs
Lines 34 to 35 in ed60599
sentry-dotnet/src/Sentry/GlobalSessionManager.cs
Lines 153 to 156 in ed60599
edit: I've asked in Discord about this.
BillyMartin1964 commentedon Mar 30, 2026
Thanks for getting to this so fast. I may have deleted the app because I was debugging and adding new models, so I'm not sure it's a persist error, but it definitely throws an exception instead of dying quietly if the file isn't there.
jamescrosswell commentedon Mar 30, 2026
I have no idea why that error is throwing (we clearly have a catch clause for it), but we should be able to work around it easily enough. See #5084
edit: Actually @BillyMartin1964 are you using AOT compilation by any chance? If so, that could explain why the try/catch isn't working - potentially the Android/Native exception handling kicks in before the .NET handing in this case. @jpnurmi dose that seem feasible?
BillyMartin1964 commentedon Mar 30, 2026
AOT only in release, but this is a debug crash
27 remaining items
jamescrosswell commentedon Apr 2, 2026
That's the first step 😉
Ideally it would be possible to demonstrate in a small sample app that could be shared with the Microsoft engineers... so it wouldn't contain any sensitive data or anything and would have minimal dependencies. There's a bit more info here on creating minimal repros.
If you're only seeing it in a bigger or more complex application, one way is to copy the project somewhere and then slowly remove stuff until you've got the smallest set of things together that reproduce the problem. That can be a fair amount of work, so for more trivial scenarios you could start from a blank slate and add things to the app until you can recreate the behaviour.
BillyMartin1964 commentedon Apr 7, 2026
Not trying to give you a hard time, just wondering why you can't get a review so you can merge?
jamescrosswell commentedon Apr 7, 2026
@BillyMartin1964 that has been approved/merged now.
There's one more minor issue to work around. One of the upstream repos we depend on for zlib in sentry-native is currently playing up (#5117). The sentry-native team are putting together a github clone/cache to workaround this. Once that's in place, we should be able to push out a new release including the fix from #5084.
Apologies in advance for the delay on this.
jamescrosswell commentedon Apr 8, 2026
@BillyMartin1964 that workaround should be included in the version 6.3.1 release that just went out.
BillyMartin1964 commentedon Apr 8, 2026
No longer crashing. Thanks for all your hard work.
Does this seem like a good setup in .Net Maui 10 or is there a better way?
#if ANDROID
options.Environment = "Android";
#endif
jamescrosswell commentedon Apr 8, 2026
Is there a reason you'r doing this?
On iOS/Android, you could just leave the
CacheDirectoryPathin which case the SDK sets it automatically:sentry-dotnet/src/Sentry.Maui/SentryMauiOptions.cs
Line 25 in 8d40272
That may be related to the original error you were seeing.
Otherwise looks OK 👍🏻
BillyMartin1964 commentedon Apr 9, 2026
Sorry. I saw it on some post somewhere. So I shouldn't need any platform specific preprocessor at all then?
jamescrosswell commentedon Apr 9, 2026
Not to set the cache directory no - we set that to a sensible default.
There are sometimes platform specific options that you can use conditional compilation to set, but it doesn't look like you're using any of those so unnecessary in your case.
BillyMartin1964 commentedon Apr 10, 2026
Thanks so much . Btw,I sent you a Linked In invitation