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

Correct Trimming RootMode for ConfigurationManager #109777

Closed
Trimatix opened this issue Nov 13, 2024 · 5 comments
Closed

Correct Trimming RootMode for ConfigurationManager #109777

Trimatix opened this issue Nov 13, 2024 · 5 comments

Comments

@Trimatix
Copy link

Trimatix commented Nov 13, 2024

Hi there, this is a followup after #101423.

I've rooted ConfigurationManager as described using TrimmerRootAssembly, but dotnet publish says that ConfigurationManager does not specify a RootMode, so I've given <TrimmerRootAssembly Include="System.Configuration.ConfigurationManager" RootMode="Library" />.

In this mode, I still get the Unhandled exception. System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize error from #101423.

Please could you advise the correct rootmode to use for this package? I haven't been able to find the documentation for RootMode online as of yet.

Many thanks in advance

(dotnet 8, linux-x64)

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Nov 13, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-configuration
See info in area-owners.md if you want to be subscribed.

@jkotas
Copy link
Member

jkotas commented Nov 13, 2024

System.Configuration.ConfigurationManager design is incompatible with trimming. It is not possible to make it work well in trimmed applications.

You may want to consider switching to a configuration library that is compatible with trimming such as https://learn.microsoft.com/en-us/dotnet/core/whats-new/dotnet-8/runtime#configuration-binding-source-generator . (This is documented at https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/incompatibilities#reflection-based-serializers .)

@steveharter
Copy link
Member

System.Configuration.ConfigurationManager design is incompatible with trimming. It is not possible to make it work well in trimmed applications.

Closing;

There is some work in v10 on this: #108464

@steveharter steveharter closed this as not planned Won't fix, can't repro, duplicate, stale Nov 13, 2024
@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label Nov 13, 2024
@sbomer
Copy link
Member

sbomer commented Nov 13, 2024

Just FYI, the work in #108464 is designed to provide better trim warnings when using ConfigurationManager - not to make it compatible with trimming.

@Trimatix
Copy link
Author

understood, thanks all 👍

@github-actions github-actions bot locked and limited conversation to collaborators Dec 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants