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

Inconsistent AssemblyVersion of Microsoft.Extensions.Logging.Abstractions between .NET and .NET462 #109044

Open
newbienewbie opened this issue Oct 19, 2024 · 2 comments
Labels
area-Extensions-Logging needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration
Milestone

Comments

@newbienewbie
Copy link

newbienewbie commented Oct 19, 2024

The latest stable Microsoft.Extensions.Logging.Abstractions.8.0.2.nupkg has an AssemblyVerion of 8.0.0.0 for .NET8 while attributing anther AssemblyVersion (8.0.0.2) for .NET462.)

This may lead confusing runtime error in some scenario.

Background

  • I have a .NET8.0 library project A that uses some 3rd-party lagecy technology and must targets .NET472. This project has a referece on Microsoft.Extensions.Logging.Abstractions.8.0.2.nupkg.
  • I have another .NET8.0 App B that refereces the above project A and also other .NET projects. The other projects also references the same Microsoft.Extensions.Logging.Abstractions.8.0.2.nupkg
  • The App B compiles. However it throws at runtime due to the mismatch Assembly version :

unable to load one of requested types,
unable to load file or assembly "Microsoft.Extensions.Logging.Abstractions, Version=8.0.0.2"

Troubleshooting

The version 8.0.0. is suspicious. After inspecting the dlls in the debug folder, I find this dll AssemblyVersion is inconsistent between .NET and .NET462.

  • download the Microsoft.Extensions.Logging.Abstractions.8.0.2
  • unzip the nupkg and change directory to the lib/ folder
  • disassemly the dll under the net8.0/ folder and we can get the AssemblyVersion is 8.0.0.0
  • disassemly the dll under the net6.0/ folder and we can get the AssemblyVersion is 8.0.0.0
  • disassemly the dll under the net462/ folder and we can get the AssemblyVersion is 8.0.0.2

Image

So I guess here's the reason why my app B crash at runtime:

  • The project A, which targets net472, use the info that the Microsoft.Extensions.Logging.Abstractions.dll is coming from lib/net462/, and thus believe that the AssemblyVersion is 8.0.0.2
  • The project B, which targets net8.0, finally copies the dll from lib/net8/, however, this dll's AssemblyVersion is 8.0.0.0 . And finally, it throws and complains that there's no assembly "Microsoft.Extensions.Logging.Abstractions, Version=8.0.0.2".

Is it better to make the AssemblyVersion the same regardless of .NET or .NET Framework ?

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Oct 19, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Oct 19, 2024
@martincostello martincostello added area-Extensions-Logging and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Oct 19, 2024
@tarekgh
Copy link
Member

tarekgh commented Oct 19, 2024

@newbienewbie could you please provide a simple repro project we can look at?

@tarekgh tarekgh added needs-author-action An issue or pull request that requires more info or actions from the author. and removed untriaged New issue has not been triaged by the area owner labels Oct 19, 2024
@tarekgh tarekgh added this to the Future milestone Oct 19, 2024
@newbienewbie
Copy link
Author

newbienewbie commented Oct 20, 2024

@newbienewbie could you please provide a simple repro project we can look at?

Hi @tarekgh , here's a minimal demo .

@dotnet-policy-service dotnet-policy-service bot added needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration and removed needs-author-action An issue or pull request that requires more info or actions from the author. labels Oct 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Extensions-Logging needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration
Projects
None yet
Development

No branches or pull requests

3 participants