iOS Deployment Issues - Could not AOT System.Configuration

Rath, Caleb 1 Reputation point
2021-03-05T23:28:57.407+00:00

Hello,

I'm in the process of developing an application for Android and iOS using Xamarin.Forms. My issue is occurring during the process of archiving my iOS project to deploy to the Apple App Store (Android is working well).

Error
The error message displayed during the archival process is

Could not AOT the assembly '/Users/user/Library/Caches/Xamarin/mtbs/builds/ProjectName.iOS/22da9d4053ecb79c8d786860f078c8703181d566bf5487370b567adfe272e007/obj/iPhone/Debug/mtouch-cache/3-Build/System.Configuration.dll

Project Details
This project is running on

  • Xamarin.Forms (5.0.0.1874)
  • Xamarin.Essentials (1.6.0)
  • Target framework: .NET Standard 2.0

The project is referencing a shared code library in the hopes of sharing code between multiple future projects.
In this shared library, there are no references directly to System.Configuration, but there are references to System.Configuration.ConfigurationManager indirectly through the following Nuget Packages

  • Microsoft.EntityFrameworkCore.SqlServer (3.1.9)
    • Microsoft.Data.SqlClient (1.1.3)
      • System.Configuration.ConfigurationManager (4.5.0)
  • Rollbar (3.14.0)
    • Microsoft.Windows.Compatibility (2.0.1)
      • System.Configuration.ConfigurationManager (4.5.0)

Resolution Steps Attempted

  • Directly referencing System.Configuration
  • Turning Linker Behaviour to "Don't Link"
  • Deleting bin/obj folders and cleaning/rebuilding
  • Archiving directly from mac

Any help resolving this issue would be greatly appreciated.

Thanks

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,287 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,174 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Cole Xia (Shanghai Wicresoft Co,.Ltd.) 6,751 Reputation points
    2021-03-08T08:22:31.387+00:00

    Hello,

    Welcome to Microsoft Q&A!

    Also as to why it works on simulator, simulators can use JIT (just in time) compilation as simulators allow run time code generation (which is what JIT compilation does, it compiles from intermediate language (IL) to machine code), however devices cannot use JIT so they must AOT (ahead of time) compile the code so that there is no IL in the app bundle… i.e. everything is pre-compiled to machine code so no run time code generation.

    System.Configuration.ConfigurationManager is not part of the .NET profile used by Xamarin. (although other parts of System.Configuration are. See the .NET API Browser: .NET API browser | Microsoft Learn .

    Besides , I see you use Microsoft.EntityFrameworkCore.SqlServer, stop using it , we should not connect directly to an Sql Server from a mobile app.

    Take a look at the official docs on on using EntityFrameworkCore with Xamarin.Forms: Getting Started with EF Core and Xamarin - EF Core | Microsoft Learn , which uses the SqlLite EF Core package for connecting to a local, on device, database .


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.