-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
ConfigurationManager is not trim compatible #49062
Comments
Tagging subscribers to this area: @safern Issue DetailsUsing the latest 6.0 SDK <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0-preview.3.21153.4" />
</ItemGroup>
</Project> using System;
using System.Configuration;
namespace ConsoleApp7
{
class Program
{
static void Main(string[] args)
{
string sAttr = ConfigurationManager.AppSettings.Get("Key0");
Console.WriteLine("hello" + sAttr);
}
}
}
Because #48428 marked all assemblies building from We should probably remove
|
Tagging subscribers to 'linkable-framework': @eerhardt, @vitek-karas, @LakshanF, @tannergooding, @sbomer Issue DetailsUsing the latest 6.0 SDK <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0-preview.3.21153.4" />
</ItemGroup>
</Project> using System;
using System.Configuration;
namespace ConsoleApp7
{
class Program
{
static void Main(string[] args)
{
string sAttr = ConfigurationManager.AppSettings.Get("Key0");
Console.WriteLine("hello" + sAttr);
}
}
}
Because #48428 marked all assemblies building from We should probably remove
|
@eerhardt I don't see any linker suppressions in System.Configuration.ConfigurationManager, is that because it's OOB package? |
Yes. We only run the linker analysis on the shared framework / runtimepack assemblies currently. #48488 tracks adding analysis for OOB libraries. |
Contributes to dotnet#49062
Verified issue. The repro steps need to call into the config system, so a couple extra steps:
|
This assembly isn't close to working with the linker given all it's use of runtime described types from user config files. The latest version doesn't have the I chatted with @eerhardt and he let me know there is not a great way (other than an rd.xml) for the assembly itself to tell the linker to root the entire assembly. For now you can workaround this with the following in the application: <ItemGroup>
<TrimmerRootAssembly Include="System.Configuration.ConfigurationManager" />
</ItemGroup> That works on |
This is not a reliable workaround. There are still going to be situations when the trimmed app is going to be broken, even with this workaround. |
I think it should be fine to close this issue. This assembly is not compatible with trimming by design, due to heavy dependency on |
The notion that this assembly is unlikely to be used in a linked application is basically saying that linked applications are unlikely to use configuration. In my 20 years of .NET development, I don't think I've ever encountered a single production application, desktop, web, mobile that didn't rely on or use configuration of some sort. The idea that a non-trivial app would not use this assembly I think is an incorrect assessment. If you can't link this assembly then linking isn't going to work for almost all real-world use-cases. Why even bother? |
There are several different configuration systems available in .NET. Some are compatible with trimming and AOT and others are not. ASP.NET Core uses |
Closing as by design; not investing in ConfigurationManager. |
Thanks for the info, that seems like a reasonable alternative approach and something I'll invest in. For those looking at native apps, it would be helpful to have a compiled list of "never going to support" assemblies so that we don't waste endless hours trying to get something that supposedly should work to work when it's not going to work "by design".
|
Note most of the libraries provide an indication of the investment level through a System.Configuration.ConfigurationManager has a Microsoft.Extensions.Configuration has a |
Thank you for the feedback. I like this idea. Submitted doc updates in dotnet/docs#36769 . Please take a look. |
Using the latest 6.0 SDK
Because #48428 marked all assemblies building from
dotnet/runtime
asIsTrimmable=true
, System.Configuration.ConfigurationManager is now getting aggressively trimmed. However, since we haven't addressed the ILLink warnings in the assembly, it is not trim compatible.We should probably remove
IsTrimmable
from this assembly until we have addressed its warnings.cc @marek-safar @sbomer
The text was updated successfully, but these errors were encountered: