Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aot 8.0 throw System.MissingMethodException #2278

Closed
lozn00 opened this issue May 19, 2023 · 4 comments
Closed

aot 8.0 throw System.MissingMethodException #2278

lozn00 opened this issue May 19, 2023 · 4 comments
Labels
area-NativeAOT-coreclr .NET runtime optimized for ahead of time compilation

Comments

@lozn00
Copy link

lozn00 commented May 19, 2023

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");

@jkotas
Copy link
Member

jkotas commented May 19, 2023

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.

@jkotas jkotas closed this as completed May 19, 2023
@jkotas jkotas added the area-NativeAOT-coreclr .NET runtime optimized for ahead of time compilation label May 19, 2023
@lozn00
Copy link
Author

lozn00 commented May 20, 2023

@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?

@jkotas
Copy link
Member

jkotas commented May 20, 2023

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

@lozn00
Copy link
Author

lozn00 commented May 20, 2023

thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-NativeAOT-coreclr .NET runtime optimized for ahead of time compilation
Projects
None yet
Development

No branches or pull requests

2 participants