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

IL2008: System.Diagnostics.FileVersionInfo: Could not resolve type 'System.SR'. #102303

Open
henning-krause opened this issue May 16, 2024 · 5 comments
Labels
area-Tools-ILLink .NET linker development as well as trimming analyzers untriaged New issue has not been triaged by the area owner

Comments

@henning-krause
Copy link

I'm trying to trim my application and get this warning:

resource ILLink.Substitutions.xml in System.Diagnostics.FileVersionInfo, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a(5,6): warning IL2008: System.Diagnostics.FileVersionInfo: Could not resolve type 'System.SR'. 

It's unclear to me what the linker is complaining about and how I can fix this. There isn't even a hint to where I use FileVersionInfo. I can't find any reference to it in my solution, so it must be further down the call-stream.

It would be great if the ILLinker could pinpoint me to the source.

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

Tagging subscribers to this area: @tommcdon
See info in area-owners.md if you want to be subscribed.

@henning-krause
Copy link
Author

By chance I found the issue:

I had a call to Assembly.GetExecutingAssembly().Location in my code. I replaced it with AppContext.BaseDirectory and the issue went away.

Still, is there a way the Linker could generate a better warning here?

@jkotas jkotas added area-Tools-ILLink .NET linker development as well as trimming analyzers and removed area-System.Diagnostics labels May 16, 2024
Copy link
Contributor

Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas
See info in area-owners.md if you want to be subscribed.

@MichalStrehovsky
Copy link
Member

The problem is that System.Diagnostics.FileVersionInfo has the resource and a manifest asking to remove the resource if UseResourceKeys feature switch is enabled, but no SR class because the resource is already dead on Windows at the time we build the assembly.

It's safe to ignore or suppress this warning. It's a harmless bug in the authoring.

@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label May 16, 2024
@MichalStrehovsky
Copy link
Member

This should be fixed.

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Tools-ILLink .NET linker development as well as trimming analyzers untriaged New issue has not been triaged by the area owner
Projects
Status: No status
Development

No branches or pull requests

3 participants