question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sentry.Maui doesn't work when deploying for iOS using "Hot Restart"

See original GitHub issue

Package

Sentry.Maui

.NET Version

6.0.304

OS

iOS

SDK Version

3.21.0-preview.3

Steps to Reproduce

  • Create a MAUI Application
  • Add Sentry NuGet
  • Add Following code:
         builder.UseSentry(options =>
         {
             // The DSN is the only required setting.
             options.Dsn = "MY DSN";


             // Use debug mode if you want to see what the SDK is doing.
             // Debug messages are written to stdout with Console.Writeline,
             // and are viewable in your IDE's debug console or with 'adb logcat', etc.
             // This option is not recommended when deploying your application.
#if DEBUG
             options.Debug = true;
#endif

             // Set TracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.
             // We recommend adjusting this value in production.
             options.TracesSampleRate = 1.0;
             options.AttachStacktrace = true;
#if ANDROID
             options.Android.AttachScreenshot = true;
#endif
             options.CacheDirectoryPath = FileSystem.Current.AppDataDirectory;
         });
  • Build & Launch with Hot Restart on a Iphone (Iphone SE 2020)

Expected Result

The application launch without any error or crash

Actual Result

The application crash.

[0:] An error occurred: ‘Could not create an native instance of the type ‘SentryCocoa.SentryOptions’: the native class hasn’t been loaded. It is possible to ignore this condition by setting ObjCRuntime.Class.ThrowOnInitFailure to false.’. Callstack: ’ at Foundation.NSObject.InitializeObject(Boolean alloced) at Foundation.NSObject…ctor(NSObjectFlag x) at SentryCocoa.SentryOptions…ctor() in //src/Sentry/obj/Release/net6.0-ios/iOS/SentryCocoa/SentryOptions.g.cs:line 59 at Sentry.SentrySdk.InitSentryCocoaSdk(SentryOptions options) in //src/Sentry/Platforms/iOS/SentrySdk.cs:line 22 at Sentry.SentrySdk.InitHub(SentryOptions options) in //src/Sentry/SentrySdk.cs:line 60 at Sentry.SentrySdk.Init(SentryOptions options) in //src/Sentry/SentrySdk.cs:line 109 at Sentry.Maui.Internal.SentryMauiInitializer.Initialize(IServiceProvider services) in /_/src/Sentry.Maui/Internal/SentryMauiInitializer.cs:line 12 at Microsoft.Maui.Hosting.MauiAppBuilder.Build() at Mobile.MauiProgram.CreateMauiApp() in C:\Users\m\source\repos\Mobile\MauiProgram.cs:line 35 at Mobile.AppDelegate.CreateMauiApp() in C:\Users\m\source\repos\Mobile\Platforms\iOS\AppDelegate.cs:line 8 at Microsoft.Maui.MauiUIApplicationDelegate.WillFinishLaunching(UIApplication application, NSDictionary launchOptions) at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) at Mobile.Program.Main(String[] args) in C:\Users\m\source\repos\Mobile\Platforms\iOS\Program.cs:line 13 at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)’

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:24 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
plattskicommented, Nov 16, 2022

This one worked for me, in the bare-bones sample that I posted, and in two other, more functional apps. I think you’ve got it, at least for me, at least for now. Tx

0reactions
mattjohnsonpintcommented, Nov 18, 2022

This is resolved in the latest 3.24.0 release. Thanks all!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Maui ios app crashes after adding reference to Sentry.Maui
Steps to Reproduce. Create a brand new Maui project; Do all the Apple stuff to get a certificate and and ad-hoc distribution profile;...
Read more >
Deploy an iOS app using hot restart - NET MAUI
In the Setup Hot Restart setup wizard, select Next: Screenshot of the first step in the setup hot restart wizard. If you don't...
Read more >
Maui Ios not working after testing hot restart
Deployment went fine and fast but app was not working. App uses skia so that is maybe a library that is static and...
Read more >
Error monitoring for .NET MAUI with Sentry - YouTube
You'll learn all about how to add Sentry to your .NET MAUI apps and see the types of insights into your errors it...
Read more >
Error when using Hot Restart - Telerik UI for .NET MAUI
Control Results Error message Accordion Pass ‑ AutoComplete Fail Yes BadgeView Fail No
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found