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

Closed
henning-krause opened this issue May 16, 2024 · 5 comments · Fixed by #103463
Closed
Labels
area-Tools-ILLink .NET linker development as well as trimming analyzers

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
MichalStrehovsky added a commit to MichalStrehovsky/runtime that referenced this issue Jun 14, 2024
…blish time

Fixes dotnet#96539.
Fixes dotnet#102303.

Two possible approaches were discussed in dotnet#96539 but doing it in illinker feels more straightforward.
MichalStrehovsky added a commit that referenced this issue Jun 17, 2024
Fixes #102303.

* Set a default value for the feature switch
* Make it possible to preinitialize the static constructor
* Fix generation of substitutions XML
* Update SR.vb to match SR.cs
* Fix resources in System.Diagnostics.FileVersionInfo.csproj

@dotnet/illink
@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label Jun 17, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jul 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Tools-ILLink .NET linker development as well as trimming analyzers
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants