microsoft / appcenter-sdk-dotnet

Development repository for the App Center SDK for .NET platforms, including Xamarin
Other
311 stars 141 forks source link

Doesn't work with .NET IL trimming in WinUI 3 project #1734

Closed JasonWei512 closed 1 year ago

JasonWei512 commented 1 year ago

Description

If I enable .NET IL trimming in a WinUI 3 project, App Center SDK stops working. It cannot send any data to the server.

Repro Steps

SampleProject.zip

  1. Create an empty .NET 7 WinUI 3 project.

  2. Install App Center nuget packages and enable it in App.xaml.cs.

  3. Run the app, and I can see STARTSESSION in Log Flow on App Center's website.

    When the app tracks an event, I can also see it in Log Flow.

    In Fiddler I can see my app sending network requests to https://appcenter.ms/api.

  4. Enable .NET IL trimming. Add these lines in .csproj file.

    <PropertyGroup>
       <PublishTrimmed>true</PublishTrimmed>
       <TrimMode>partial</TrimMode>
       <BuiltInComInteropSupport>true</BuiltInComInteropSupport>
    </PropertyGroup>

    Now when my app runs, I can't see anything in Log Flow.

    When the app tracks an event, I can see "System.MissingMethodException" in "System.Private.CoreLib.dll" in Visual Studio's debugger output.

    In Fiddler I can't see any network request to App Center server.

    I guess this is related to json serialization.

Details

  1. What is your app platform (Xamarin.Android or Xamarin.iOS or UWP)?

    • WinUI 3 (.NET 7)
  2. If using Xamarin.Forms or if using portable/shared code to call our SDK APIs, are you using shared project, PCL code or .NET standard code for the application? Which .NET standard version or which PCL profile?

    • N/A
  3. Which SDK version are you using?

    • 5.0.1
  4. Which OS version did you experience the issue on?

    • Windows 11 22623.1245
  5. What device version did you see this error on? Were you using an emulator or a physical device?

    • On my desktop PC and Surface Pro
  6. What third party libraries are you using?

    • Microsoft.WindowsAppSDK 1.2.230313.1
    • Microsoft.Windows.SDK.BuildTools 10.0.22621.756
  7. Please enable verbose logging for your app using AppCenter.LogLevel = LogLevel.Verbose before your call to AppCenter.Start(...) and include the logs here:

    2023-03-21 19:34:01.621 [AppCenter] DEBUG: Use lifecycle for WinUI applications.
    2023-03-21 19:34:01.674 [AppCenter] DEBUG: No named identifier found in appSecret; using as-is
    2023-03-21 19:34:01.770 [AppCenter] DEBUG: Creating database at: C:\Users\JasonWei\AppData\Local\Microsoft\AppCenter\8f662e18-d7ac-4a41-98e9-cecd41adfde0\Logs.db
    2023-03-21 19:34:01.790 [AppCenter] DEBUG: AddChannel(core)
    2023-03-21 19:34:01.803 [AppCenter] INFO: App Center SDK configured successfully.
    2023-03-21 19:34:01.809 [AppCenter] DEBUG: AddChannel(analytics)
    2023-03-21 19:34:01.815 [AppCenterAnalytics] DEBUG: SessionTracker.Resume
    2023-03-21 19:34:01.820 [AppCenter] DEBUG: Invoke EnqueuingLog event for channel 'analytics'
    2023-03-21 19:34:01.858 [AppCenter] INFO: 'Analytics' service started.
    2023-03-21 19:34:01.860 [AppCenter] DEBUG: Invoke EnqueuingLog event for channel 'core'
    2023-03-21 19:34:01.870 [AppCenter] DEBUG: Set max storage size.
    2023-03-21 19:34:01.872 [AppCenter] DEBUG: CheckPendingLogsInternal(core) pending log count: 0
    2023-03-21 19:34:01.874 [AppCenter] INFO: Found 3 pages in the database.
    2023-03-21 19:34:01.876 [AppCenter] INFO: Changed maximum database size to 10485760 bytes.
    2023-03-21 19:34:01.878 [AppCenter] DEBUG: CheckPendingLogsInternal(analytics) pending log count: 0
    Exception thrown: 'System.MissingMethodException' in System.Private.CoreLib.dll
    Exception thrown: 'System.MissingMethodException' in System.Private.CoreLib.dll
    Exception thrown: 'System.MissingMethodException' in System.Private.CoreLib.dll
    Exception thrown: 'System.MissingMethodException' in System.Private.CoreLib.dll
    Exception thrown: 'System.MissingMethodException' in System.Private.CoreLib.dll
    Exception thrown: 'System.MissingMethodException' in System.Private.CoreLib.dll
    Exception thrown: 'System.MissingMethodException' in System.Private.CoreLib.dll
    Exception thrown: 'System.MissingMethodException' in System.Private.CoreLib.dll
    Exception thrown: 'System.MissingMethodException' in System.Private.CoreLib.dll
    Exception thrown: 'System.MissingMethodException' in System.Private.CoreLib.dll
    
    // Track event
    
    2023-03-21 19:34:30.003 [AppCenter] DEBUG: Invoke EnqueuingLog event for channel 'analytics'
    Exception thrown: 'System.MissingMethodException' in System.Private.CoreLib.dll
    Exception thrown: 'System.MissingMethodException' in System.Private.CoreLib.dll
    Exception thrown: 'System.MissingMethodException' in System.Private.CoreLib.dll
    Exception thrown: 'System.MissingMethodException' in System.Private.CoreLib.dll
    Exception thrown: 'System.MissingMethodException' in System.Private.CoreLib.dll

Miscellaneous

Related issues:

AnatolyPristensky commented 1 year ago

Hello @JasonWei512, sorry for the late answer, We've filed an item on our internal board for this request. Will update this thread once got results.

tipa commented 1 year ago

@AnatolyPristensky Any updates on this problem? What did the "internal board" decide?

DmitriyKirakosyan commented 1 year ago

As we do not have plans to add support for this feature in the next year, I'm closing the issue.