Giter Club home page Giter Club logo

Comments (14)

jamescrosswell avatar jamescrosswell commented on June 12, 2024

Thanks for the report @softlion. This is probably a duplicate of:

from sentry-dotnet.

softlion avatar softlion commented on June 12, 2024

Thanks for the report @softlion. This is probably a duplicate of:

That does not seem the same at all to me.
Key differences:

  • This one is about the Sentry Logging extension nuget. The linked issue is about the Sentry Maui nuget, for which I have no issue.
  • On this one the crash is in the .NET service container that can't find some constructor. The linked issue is about a native crash in a native lib.
  • This one is on iOS. The linked issue is on Mac.
  • This one happens only in Release mode. The linked issue happens both in debug and release mode.

from sentry-dotnet.

softlion avatar softlion commented on June 12, 2024

Here is the full stack trace:

Autofac.Core.Activators.Reflection.NoConstructorsFoundException
No constructors on type 'Microsoft.Extensions.Logging.Configuration.LoggingConfiguration'
can be found with the constructor finder 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder'.

An exception was thrown while activating Microsoft.Extensions.Logging.Logger1[[Microsoft.Maui.Hosting.MauiApp, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] -> Microsoft.Extensions.Logging.LoggerFactory -> λ:Microsoft.Extensions.Logging.ILoggerProvider[] -> Sentry.Extensions.Logging.SentryLoggerProvider -> Microsoft.Extensions.Options.UnnamedOptionsManager1[[Sentry.Extensions.Logging.SentryLoggingOptions, Sentry.Extensions.Logging, Version=4.4.0.0, Culture=neutral, PublicKeyToken=fba2ec45388e2af0]] -> Microsoft.Extensions.Options.OptionsFactory1[[Sentry.Extensions.Logging.SentryLoggingOptions, Sentry.Extensions.Logging, Version=4.4.0.0, Culture=neutral, PublicKeyToken=fba2ec45388e2af0]] -> λ:Microsoft.Extensions.Options.IConfigureOptions1[[Sentry.Extensions.Logging.SentryLoggingOptions, Sentry.Extensions.Logging, Version=4.4.0.0, Culture=neutral, PublicKeyToken=fba2ec45388e2af0]][] -> Sentry.Extensions.Logging.SentryLoggingOptionsSetup -> Microsoft.Extensions.Logging.Configuration.LoggerProviderConfiguration`1[[Sentry.Extensions.Logging.SentryLoggerProvider, Sentry.Extensions.Logging, Version=4.4.0.0, Culture=neutral, PublicKeyToken=fba2ec45388e2af0]] -> Microsoft.Extensions.Logging.Configuration.LoggerProviderConfigurationFactory -> λ:Microsoft.Extensions.Logging.Configuration.LoggingConfiguration[].

I would like to add

[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(Microsoft.Extensions.Logging.Configuration.LoggingConfiguration))]

But that don't work as LoggingConfiguration is internal.

It may be a bug in the Microsoft.Extensions.Logging.Configuration nuget, as that also happens with the SimpleConsoleLogger (but does not happen with the ConsoleLogger).

A workaround for you may be to NOT use Microsoft.Extensions.Logging.Configuration when it's not needed.

from sentry-dotnet.

jamescrosswell avatar jamescrosswell commented on June 12, 2024

That does not seem the same at all to me.

You're right - my mistake... we'll try to reproduce.

from sentry-dotnet.

softlion avatar softlion commented on June 12, 2024

I switched to seq logging instead of sentry as a temporary workaround. That is working. Maybe because the seq nuget is very simple and does not use the ms logging configuration nuget.

from sentry-dotnet.

softlion avatar softlion commented on June 12, 2024

What's curious is, the warnings logs are now logged to sentry too, even if I did not add the sentry logging call to MauiApp.cs

from sentry-dotnet.

jamescrosswell avatar jamescrosswell commented on June 12, 2024

Hi @softlion, I took another look at this but it's not exactly easy to reproduce. Publishing an app to TestFlight would require setting up provisioning profiles etc.

I wondered if it might be quicker to get you to share the exception details and stack trace that you're seeing or any logs that get captured when you're running this app in TestFlight?

from sentry-dotnet.

jamescrosswell avatar jamescrosswell commented on June 12, 2024

Apologies, I see you provided details above.

I think I must always be looking into this issue when my brain is fried 🤯 (that or my brain is permanently fried).

from sentry-dotnet.

jamescrosswell avatar jamescrosswell commented on June 12, 2024

OK so now I'm actually caught up and looking at the exception details that you provided (ages ago, apologies once again)... I'm not sure if this is a Sentry thing or an Autofac thing.

The error appears to be coming from Autofac when it attempts to create an instance of Microsoft.Extensions.Logging.Configuration.LoggingConfiguration:

Autofac.Core.Activators.Reflection.NoConstructorsFoundException
No constructors on type 'Microsoft.Extensions.Logging.Configuration.LoggingConfiguration'
can be found with the constructor finder 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder'.

And I take it from the workaround that you were looking into, this is related to trimming when building the application in release mode.

Have you tried asking the Autofac folks for suggestions? Perhaps they've already seen this before?

By the way, Sentry should hook up logging in the call to MauiAppBuilder.UseSentry:

services.AddSingleton<ILoggerProvider, SentryMauiLoggerProvider>();

So I don't think you need the call to ILoggingBuilder.AddSentry (where you configure Autofac as the DI container).

from sentry-dotnet.

softlion avatar softlion commented on June 12, 2024

By the way, Sentry should hook up logging in the call to MauiAppBuilder.UseSentry:

Maybe you missed it, but I wrote that it is both logging and reporting crashes when using UseSentry.

When I added Logging.AddSentry() it stopped working in release mode. At that time I did not know that UseSentry() already hooks the logging.

That is curious that logging to sentry is working even when I don't follow your doc for it.

from sentry-dotnet.

jamescrosswell avatar jamescrosswell commented on June 12, 2024

Maybe you missed it, but I wrote that it is both logging and reporting crashes when using UseSentry.

I tried using the following code to try to reproduce on a simulator (iOS 17.2) and on a physical device, but the app seems to work fine in both cases (running "Release" configuration, not "Debug"):

    public static MauiApp CreateMauiApp()
    {
        var builder = MauiApp.CreateBuilder();
        builder.ConfigureContainer(new AutofacServiceProviderFactory(), autofacBuilder => { });
        builder
            .UseMauiApp<App>()
            .UseSentry(options =>
            {
                // ...
            })
            .ConfigureFonts(fonts =>
            {
                fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
                fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
            });

        builder.Logging
            .SetMinimumLevel(LogLevel.Trace)
            .AddSentry();

        return builder.Build();
    }

Is that what you see as well? So you only get this issue when running the application in TestFlight?

Without being able to reproduce the problem, it's hard to guess at what might be causing it.

Have you tried without Autofac? Does your app crash in release mode when using Microsoft's DependencyInjection?

from sentry-dotnet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.