runtime: Error loading System.Buffers, Version=4.0.2.0 when using AspNet Core SignalR C# client in a .NET Framework 4.7.1 Web test
- clone to get the signalr chat sample at https://github.com/aspnet/SignalR-samples/tree/master/ChatSample
- open the solution, restore nuget package and Ctrl+F5 to run the service
- clone the webtest repro project at https://github.com/jeremymeng/WebTestRepro
- open
WebAndLoadTestProject2.sln
, restore then build the project. You will need the web test payload for your visual studio installation to support this type of project. - notice that the
bin\Debug
directory has 41 files - now open the webtest.webtest file in visual studio. select Debug Test, pause before starting from the drop down
- under web test solution folder, check the most recent
TestResults\<user_machineName timestamp>\Out
folder. This is where the test is actually running. The folder only has 25 files under it. (This could be a bug in Web Test framework. I already logged a separate internal bug against VSTT team) - copy all files from bin\Debug folder into the Out folder (skip existing)
- click Run button (the first button) to continue the web test
Actual:
System.IO.InvalidDataException
HResult=0x80131501
Message=Invalid negotiation response received.
Source=Microsoft.AspNetCore.Http.Connections.Common
StackTrace:
at Microsoft.AspNetCore.Http.Connections.NegotiateProtocol.ParseResponse(Stream content)
at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.<NegotiateAsync>d__45.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.<GetNegotiationResponseAsync>d__52.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.<SelectAndStartTransport>d__44.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.<StartAsyncCore>d__41.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.<StartAsync>d__40.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.SignalR.Client.HttpConnectionFactory.<ConnectAsync>d__3.MoveNext()
at Microsoft.AspNetCore.SignalR.Client.HttpConnectionFactory.<ConnectAsync>d__3.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.SignalR.Client.HubConnection.<StartAsyncCore>d__31.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.SignalR.Client.HubConnection.<StartAsync>d__24.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at iRel8.Service.WebTests.WebtestPlugins.SignalRJoinRoomPlugin.<PreRequest>d__0.MoveNext() in C:\github\jeremymeng\WebTestRepro\WebAndLoadTestProject2\SignalRJoinRoomPlugin.cs:line 16
Inner Exception 1:
TypeInitializationException: The type initializer for 'JsonArrayPool`1' threw an exception.
Inner Exception 2:
FileNotFoundException: Could not load file or assembly 'System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 3
- Comments: 37 (16 by maintainers)
The error people get when they hit this is just a symptom, and unfortunately it is a symptom that may be caused by many different root causes. The most common case why people hit this issue is because they are targetting .NET Framework in their app, and for one reason or another the tooling isn’t fully detecting that System.Buffers implementation targets .NET Standard, or it may detect it but it won’t include the required facades in the bin output folder because of custom project settings. That means that if you try to summarize most problems really happen because System.Buffers implementation targets .NET Standard, so what we did different in 4.5.1 was to provide an implementation in the package that also targets .NET Framework. With this, most projects that were having custom logic or settings causing this problem to arise should be fixed.
@sean-mcleish the only way we found was to configure reminding in the Web.config file, like this:
There is a new version of System.Buffers package that will ship some time this month which will make most of these problems go away. Package version will be 4.5.1.
I have the exact same problem, I tried everything I could find on the internet i’m completely clueless now…
My project is a WebTest project (Output Type of Class Library). I don’t get any warnings or errors when building the project in Visual Studio. There are no *.config files under
bin\Debug
even I have auto generate binding redirects onThe config files I saw from fuslog are
Okay, I found a temporary solution. The problem was that I dynamically loaded my web class library from a main application. The dynamic loading works by searching for all *.dll that implement a certain interface. The main application looks at its own *.exe.config and ignores the *.dll.config of the web class library. The current fix: add the redirects in the app.config of the main application. The desired fix: the main application also considers the *.dll.configs of all applications. I need to get a little more information about this.
Same issue observed on upgrading project to .NET framework 4.7.2 even after upgrading all nuget packages.
Error: Could not load file or assembly ‘System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) Could not load file or assembly ‘System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
======== Even getting same error after upgrading System.Buffers to available versions on nuget 4.0.0/ 4.3.0 / 4.4.0 / 4.5.0
============
Below is my app.config file
<?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> </configSections> <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /></startup> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.0.6.0" newVersion="4.0.6.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" /> </dependentAssembly> </assemblyBinding> </runtime> </configuration>