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

System.Numerics.Vectors binding redirect missing #41597

Closed
jc1001 opened this issue Aug 31, 2020 · 4 comments
Closed

System.Numerics.Vectors binding redirect missing #41597

jc1001 opened this issue Aug 31, 2020 · 4 comments

Comments

@jc1001
Copy link

jc1001 commented Aug 31, 2020

Description

I have a .NET Core 2 application that is targeting the full .NET Framework (v4.8).
It hosts a web server (using HttpSys) that exposes a SignalR hub.
I can make a successful call from a client (in this case a .NET console application) to the SignalR hub.
Both the client and the server applications are making use of the new "SDK-style" projects.

When I upgrade the System.Collections.Immutable library on the server to v1.7.1, the connection call from the client application to the SignalR hub on the server fails with a WebSocketException.

Using the fusion log viewer, I've traced the problem to a missing binding redirect - the server code is trying to load System.Numerics.Vectors v4.1.3, while the output directory contains v4.1.4. If I add the required binding redirect manually in the app.config, everything works as expected.

Fusion log viewer:
Fusion log viewer

Binding redirect:
Binding redirect

I had a look (and tried the suggestions) in the following issues, but did not manage to solve the problem:
#27506
#26370
dotnet/sdk#901

To Reproduce

I have attached a sample solution that reproduces the problem.
SignalRBug.zip

The solution contains 2 projects: "Client" and "Server".
An instance of "Server" must be running (hosting on http://localhost:8080) before you can execute "Client".
The example (as attached) will run without any errors.

When you edit the Server.csproj file to include the latest version of the System.Collections.Immutable library, the client application will fail as described above.

Configuration

  • .NET Framework 4.8
  • Microsoft Visual Studio Enterprise 2019, Version 16.7.1
  • Windows 10, version 2004 (Build: 19041.450)

Thank you. If you require any additional information, please let me know.

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-System.Numerics untriaged New issue has not been triaged by the area owner labels Aug 31, 2020
@ghost
Copy link

ghost commented Aug 31, 2020

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

@tannergooding
Copy link
Member

CC. @ericstj.

Seems devs are still having issues with System.Numerics.Vectors bindings out of the box, is there anything we can do here to improve the situation so the default path "just works"?

@ericstj
Copy link
Member

ericstj commented Aug 31, 2020

BindingRedirects will always be required when using nuget packages on desktop. Usually MSBuild will automatically detect when these are needed, but it is missing the case for System.Numerics.Vectors here.

This is because the conflict is coming from the two assemblies:
System.Memory -> System.Numerics.Vectors, Version=4.1.4.0
System.Net.WebSockets.WebSocketProtocol -> System.Numerics.Vectors, Version=4.1.3.0

The version of System.Net.WebSockets.WebSocketProtocol referenced is 4.5.1 from Microsoft.AspNetCore.WebSockets.

That version of WebSocketProtocol uses a different reference assembly than implementation and its reference assembly does not use System.Numerics.Vectors, so MSBuild never sees the conflict. If you reference a newer version of System.Net.WebSockets.WebSocketProtocol the problem goes away:

<PackageReference Include="System.Net.WebSockets.WebSocketProtocol" Version="4.7.1" />

This version uses a newer version of System.Numerics.Vectors, so there is no conflict. This version also ensures it's implementation assembly is exposed for reference on .NETFramework, so even if there were a conflict MSBuild would see it and write the bindingRedirect.

@jc1001
Copy link
Author

jc1001 commented Sep 1, 2020

Thank you for the detailed (and quick) response. I can confirm that my example application is working when I add the reference to the later version of System.Net.WebSockets.WebSocketProtocol.

I'll close this issue and reference the answer on the aspnetcore project (where I initially logged the issue) - hopefully they can update the necessary NuGet packages to the working versions. If not, I can always use the (newer reference) workaround.

@jc1001 jc1001 closed this as completed Sep 1, 2020
@tannergooding tannergooding removed the untriaged New issue has not been triaged by the area owner label Sep 14, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants