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.
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
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 ?
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
A
that uses some 3rd-party lagecy technology and must targets .NET472. This project has a referece onMicrosoft.Extensions.Logging.Abstractions.8.0.2.nupkg
.B
that refereces the above projectA
and also other .NET projects. The other projects also references the sameMicrosoft.Extensions.Logging.Abstractions.8.0.2.nupkg
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.
lib/
foldernet8.0/
folder and we can get the AssemblyVersion is 8.0.0.0net6.0/
folder and we can get the AssemblyVersion is 8.0.0.0net462/
folder and we can get the AssemblyVersion is 8.0.0.2So I guess here's the reason why my app B crash at runtime:
A
, which targets net472, use the info that the Microsoft.Extensions.Logging.Abstractions.dll is coming fromlib/net462/
, and thus believe that the AssemblyVersion is 8.0.0.2B
, which targets net8.0, finally copies the dll fromlib/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 ?