Skip to content

aot 8.0 throw System.MissingMethodException #2278

Closed

Description

@lozn00
Unhandled Exception: System.MissingMethodException: No parameterless constructor defined for type 'System.Configuration.ClientConfigurationHost'.
   at System.ActivatorImplementation.CreateInstance(Type, Boolean) + 0xfe
   at System.Configuration.Configuration..ctor(String, Type, Object[]) + 0x5b
   at System.Configuration.ClientConfigurationHost.OpenExeConfiguration(ConfigurationFileMap, Boolean, ConfigurationUserLevel, String) + 0x104
   at System.Configuration.ConfigurationManager.OpenExeConfigurationImpl(ConfigurationFileMap, Boolean, ConfigurationUserLevel, String, Boolean) + 0x4d
   at webapi_test.utils.ConfigUtil.initServerURLConfig() + 0x19
   at Program.<Main>$(String[] args) + 0x2e
   at webapi_mes!<BaseAddress>+0x11d0039

code

   Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            RuntimeSaveConfig.updateServer = readConfigValue(configuration, "UpdateServer");
            RuntimeSaveConfig.mesServer = readConfigValue(configuration, "MesServer");

Activity

  1. jkotas commented on May 19, 2023

    @jkotas
    Member

    The native AOT projects lives in http://github.com/dotnet/runtime now. Please open any issues http://github.com/dotnet/runtime.

    System.Configuration.ConfigurationManager package is not compatible with trimming and AOT (tracked by dotnet/runtime#49062). You should see a warning like Assembly 'System.Configuration.ConfigurationManager' produced trim warnings. during build. This warning says that there is a good chance that the app is not going to work.

    Duplicate of dotnet/runtime#49062 that tracks trimming compatibility for System.Configuration.ConfigurationManager package.

  2. lozn00 commented on May 20, 2023

    @lozn00
    Author

    @jkotas Can you give some advice? What library should I use instead of ConfigurationManager? Used to read and write files

    Can you give some advice? What other utility classes support reading and writing configuration, and if I can't use ConfigurationManager, then what should I use?

  3. jkotas commented on May 20, 2023

    @jkotas
    Member

    Microsoft.Extensions.Configuration is going to be the trimming and AOT friendly in .NET 8 with the introduction of configuration source generators: https://devblogs.microsoft.com/dotnet/announcing-dotnet-8-preview-3/#introducing-the-configuration-binding-source-generator

  4. lozn00 commented on May 20, 2023

    @lozn00
    Author

    thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-NativeAOT-coreclr.NET runtime optimized for ahead of time compilation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions