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

The nuget package: https://www.nuget.org/api/v2/package/System.Buffers/4.5.1 has mismatched assembly versions. #47949

Open
KevinRansom opened this issue Feb 6, 2021 · 6 comments

Comments

@KevinRansom
Copy link
Member

The nuget package: https://www.nuget.org/api/v2/package/System.Buffers/4.5.1 has mismatched assembly versions.

Which requires binding redirects on the desktop to successfully bind.

Download the nuget package : https://www.nuget.org/api/v2/package/System.Buffers/4.5.1

Extract the files:
use ildasm or some other mechanism to examine the assembly version numbers.

ref\net45\System.Buffers.dll                      Version:   4.0.3.0
ref\netstandard1.1\System.Buffers.dll       Version:   4.0.2.0
ref\netstandard2.0\System.Buffers.dll       Version:   4.0.2.0

lib\net461\System.Buffers.dll                    Version:   4.0.3.0

This is an issue because if I build a library for netstandard2.0, and reference it from an app built for net472 the app needs a binding redirect to correctly execute.

@dotnet-issue-labeler dotnet-issue-labeler bot added area-System.Buffers untriaged New issue has not been triaged by the area owner labels Feb 6, 2021
@ghost
Copy link

ghost commented Feb 6, 2021

Tagging subscribers to this area: @tannergooding, @pgovind, @GrabYourPitchforks
See info in area-owners.md if you want to be subscribed.

Issue Details

The nuget package: https://www.nuget.org/api/v2/package/System.Buffers/4.5.1 has mismatched assembly versions.

Which requires binding redirects on the desktop to successfully bind.

Download the nuget package : https://www.nuget.org/api/v2/package/System.Buffers/4.5.1

Extract the files:
use ildasm or some other mechanism to examine the assembly version numbers.

ref\net45\System.Buffers.dll                      Version:   4.0.3.0
ref\netstandard1.1\System.Buffers.dll       Version:   4.0.2.0
ref\netstandard2.0\System.Buffers.dll       Version:   4.0.2.0

lib\net461\System.Buffers.dll                    Version:   4.0.3.0

This is an issue because if I build a library for netstandard2.0, and reference it from an app built for net472 the app needs a binding redirect to correctly execute.

Author: KevinRansom
Assignees: -
Labels:

area-System.Buffers, untriaged

Milestone: -

@huoyaoyuan
Copy link
Member

#45921

@danmoseley
Copy link
Member

@Anipik

@saucecontrol
Copy link
Member

saucecontrol commented Feb 6, 2021

Not a direct fix, but if you're targeting .NET Standard and intend compatibility with .NET Framework, your users will have a better experience in general if you multi-target your library for both net461 and netstandard2.0. That will fix your issue with System.Buffers as a side effect, but there are other benefits as well.

Rick Strahl has a good writeup on that here, and the same recommendation is given in Microsoft's guidance for library developers here.

✔️ CONSIDER adding a target for net461 when you're offering a netstandard2.0 target.

Using .NET Standard 2.0 from .NET Framework has some issues that were addressed in .NET Framework 4.7.2. You can improve the experience for developers that are still on .NET Framework 4.6.1 - 4.7.1 by offering them a binary that is built for .NET Framework 4.6.1.

@KevinRansom
Copy link
Member Author

KevinRansom commented Feb 7, 2021

@saucecontrol ,
If I build and reference ref/netstandard2.0 and the assembly verision is 4.0.2.0 and The corresponding lib/netstandard2.0 has an assembly version of 4.0.3.0 then on the desktop a binding redirect is necessary.

For developers building software that is a plugin, it is very hard to get an app to add the necessary binding redirect. I would suggest that having different version numbers for ref and lib in the same nuget package is just broken.

@saucecontrol
Copy link
Member

saucecontrol commented Feb 7, 2021

Correct, if the ref/lib versions don't match, the binding redirect is necessary on desktop. However, if you multi-target, the net461 version of your library in the package would pick up the reference to 4.0.3 while the netstandard2.0 copy of your library would reference 4.0.2 (this doesn't matter since netfx is the only that one won't load without an exact version match). I've been through this in my own libraries, and multi-targeting, along with careful selection of dependency versions has solved the issue for my users.

having different version numbers for ref and lib in the same nuget package is just broken.

I couldn't agree more, and I said as much over on #26370. You might find that issue informative, if only so you can get a picture of how/why the current broken state came to be ;)

@tannergooding tannergooding added this to the Future milestone Jul 12, 2021
@tannergooding tannergooding removed the untriaged New issue has not been triaged by the area owner label Jul 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants