RavenDB 4.2.0: UnitTest is failing System.Buffers

125 views
Skip to first unread message

Severin Meyer

unread,
May 28, 2019, 3:52:50 PM5/28/19
to RavenDB - 2nd generation document database
When I run a UnitTest project in VisualStudio, I get an error about System.Buffers not found.
Using RavenDB Client in a normal .net Framework Project doesn't throw this exception.

I have removed and readded nuget packages, changed the framework version, nothing helped.

Any Ideas?

Visual Studio 2019 16.1.1
Windows 10 Pro x64 1903
RavenDB 4.2.0

Message: Test method RavenDBTest.RavenDBTestDriver.IndexProjectionTest threw exception: 
Raven.Client.Exceptions.RavenException: An exception occurred while contacting http://127.0.0.1:64593/admin/databases?name=IndexProjectionTest_1&replicationFactor=1.
System.Net.Http.HttpRequestException: Fehler beim Kopieren von Inhalt in einen Stream. ---> System.IO.FileLoadException: Die Datei oder Assembly "System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" oder eine Abhängigkeit davon wurde nicht gefunden. Die gefundene Manifestdefinition der Assembly stimmt nicht mit dem Assemblyverweis überein. (Ausnahme von HRESULT: 0x80131040)
   bei Sparrow.Json.BlittableJsonReaderObject.InsertionOrderProperties..ctor(Int32 size)
   bei Sparrow.Json.BlittableJsonReaderObject.GetPropertiesByInsertionOrder() in C:\Builds\RavenDB-Stable-4.2\42009\src\Sparrow\Json\BlittableJsonReaderObject.cs:Zeile 860.
   bei Sparrow.Json.AbstractBlittableJsonTextWriter.WriteObject(BlittableJsonReaderObject obj) in C:\Builds\RavenDB-Stable-4.2\42009\src\Sparrow\Json\BlittableJsonTextWriter.cs:Zeile 174.
   bei Sparrow.Json.JsonOperationContext.Write(Stream stream, BlittableJsonReaderObject json) in C:\Builds\RavenDB-Stable-4.2\42009\src\Sparrow\Json\JsonOperationContext.cs:Zeile 1046.
   bei Raven.Client.ServerWide.Operations.CreateDatabaseOperation.CreateDatabaseCommand.<>c__DisplayClass5_0.<CreateRequest>b__0(Stream stream) in C:\Builds\RavenDB-Stable-4.2\42009\src\Raven.Client\ServerWide\Operations\CreateDatabaseOperation.cs:Zeile 57.
   bei Raven.Client.Json.BlittableJsonContent.SerializeToStreamAsync(Stream stream, TransportContext context) in C:\Builds\RavenDB-Stable-4.2\42009\src\Raven.Client\Json\BlittableJsonContent.cs:Zeile 24.
   bei System.Net.Http.HttpContent.LoadIntoBufferAsync(Int64 maxBufferSize)
   --- Ende der internen Ausnahmestapelüberwachung ---
   bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   bei Raven.Client.Http.RequestExecutor.<ExecuteAsync>d__77`1.MoveNext() in C:\Builds\RavenDB-Stable-4.2\42009\src\Raven.Client\Http\RequestExecutor.cs:Zeile 763..
The server at http://127.0.0.1:64593/admin/databases?name=IndexProjectionTest_1&replicationFactor=1 responded with status code: ServiceUnavailable. ---> System.Net.Http.HttpRequestException: Fehler beim Kopieren von Inhalt in einen Stream. ---> System.IO.FileLoadException: Die Datei oder Assembly "System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" oder eine Abhängigkeit davon wurde nicht gefunden. Die gefundene Manifestdefinition der Assembly stimmt nicht mit dem Assemblyverweis überein. (Ausnahme von HRESULT: 0x80131040)

Paweł Pekról

unread,
May 28, 2019, 4:57:23 PM5/28/19
to rav...@googlegroups.com
Hi Severin,

It looks like System.Buffers, the direct dependecy of RavenDB Client is missing. it should be installed with the client nuget package. I've just created 2 projects in VS2019 (16.1.1), one for .NET Core, second one for .NET Framework and everything seems to be fine. Managed to initialize document store and created a database without any issues. Can you check if System.Buffers is in References (.NET Framework) or Dependencies (.NET Core)?

If there will still be a problem, please send us the project where it is reproducible and we will check what is going on.


Paweł Pekról
Head of Development   /   Hibernating Rhinos LTD
Support:  sup...@ravendb.net
  


--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
To post to this group, send email to rav...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ravendb/2ba8ac51-6072-41c6-a1ff-c95b3780d917%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Severin Meyer

unread,
May 29, 2019, 4:11:11 AM5/29/19
to RavenDB - 2nd generation document database
Hi Pawel

The System.Buffers Package 4.5 will be installed by nuget, but as it is not listed when using PackageReference I'm unsure what is used on runtime.
In the output directory, the version 4.6.26515.6 will be copied, which in fact will be 4.0.3.
The "normal" WPF-Project as also to the UnitTest is copying the same dll.

It seems, that the running context of a UnitTest is different in resolving the proper dlls.

Attached the VS-Test project.
 
RavenDBTest.zip

Severin Meyer

unread,
May 29, 2019, 2:18:36 PM5/29/19
to RavenDB - 2nd generation document database
I could solve the problem by referencing the following nuget package in the Test-Project:
Microsoft.NET.Test.Sdk

Paweł Pekról

unread,
May 29, 2019, 3:58:17 PM5/29/19
to rav...@googlegroups.com
Hi,

I've reproduced your issue. I think that the problem is with NuGet not adding appropriate binding redirects to the App.config when new format is used (new format adds everything to csproj not package.json).

If you will add 'App.config' with following content:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <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>
    </assemblyBinding>
  </runtime>
</configuration>

Then everything is working fine. This is actually what NuGet adds when you are using old package.json format. There is a lot of noise regarding this subject e.g. here https://github.com/dotnet/corefx/issues/33148
Notice how many issues are referenced there.

I hope that this solves your problem and enables you to continue your work.

Paweł Pekról
Head of Development   /   Hibernating Rhinos LTD
Support:  sup...@ravendb.net
  

On Wed, May 29, 2019 at 8:18 PM Severin Meyer <s.m...@bitworld.ch> wrote:
I could solve the problem by referencing the following nuget package in the Test-Project:
Microsoft.NET.Test.Sdk

--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
To post to this group, send email to rav...@googlegroups.com.

Severin Meyer

unread,
May 29, 2019, 6:22:02 PM5/29/19
to RavenDB - 2nd generation document database
I think the main cause of this problem is, that the UnitTest is running from Framework 4.5 and not 4.8.
In the test output there is a hint about this missmatch:
   [Warning] Der Testlauf verwendet DLLs, die für das Framework .NETFramework,Version=v4.5 und die Plattform X64 erstellt wurden. Die folgenden DLLs sind nicht Teil der Ausführung: 
   "RavenDBTest.dll" wurde für das Framework 4.8 und die Plattform AnyCPU erstellt.

I haven't found a valid way to force the UnitTest to run on 4.8. The highest valid/accepted value seems to be Framework45.
But referencing Microsoft.NET.Test.Sdk seems to do the magic binding redirection automatically.

So this seems to work without any problems now.

Reply all
Reply to author
Forward
0 new messages