Exception while saving to Raven

2

I'm getting an exception while trying to save an entity to Raven in one of our environments.

Here are details:

Application Target Framework: .NET Core 2.1

RavenDB.Client Version: 4.1.2

.Net Core Runtime and Hosting Bundle installed on the server:

2.0.5

2.1.3

2.1.6

2.2.0

(We have multiple versions installed since it is a shared environment with multiple applications hosted)

Exception:

System.IO.FileLoadException: Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
   at Sparrow.Json.UnmanagedWriteBuffer.Write(Byte* buffer, Int32 count)
   at Sparrow.Json.BlittableWriter`1.WriteValue(Byte* buffer, Int32 size, FastList`1 escapePositions, BlittableJsonToken& token, UsageMode mode, Nullable`1 initialCompressedSize) in C:\Builds\RavenDB-Stable-4.1\src\Sparrow\Json\BlittableWriter.cs:line 555
   at Sparrow.Json.BlittableJsonDocumentBuilder.ReadInternal[TWriteStrategy]() in C:\Builds\RavenDB-Stable-4.1\src\Sparrow\Json\BlittableJsonDocumentBuilder.cs:line 320
   at Sparrow.Json.JsonOperationContext.ReadObjectInternal(Object builder, String documentId, UsageMode mode, IBlittableDocumentModifier modifier) in C:\Builds\RavenDB-Stable-4.1\src\Sparrow\Json\JsonOperationContext.cs:line 619
   at Raven.Client.Documents.Session.InMemoryDocumentSessionOperations.StoreEntityInUnitOfWork(String id, Object entity, String changeVector, DynamicJsonValue metadata, ConcurrencyCheckMode forceConcurrencyCheck) in C:\Builds\RavenDB-Stable-4.1\src\Raven.Client\Documents\Session\InMemoryDocumentSessionOperations.cs:line 741
   at Raven.Client.Documents.Session.InMemoryDocumentSessionOperations.StoreInternal(Object entity, String changeVector, String id, ConcurrencyCheckMode forceConcurrencyCheck) in C:\Builds\RavenDB-Stable-4.1\src\Raven.Client\Documents\Session\InMemoryDocumentSessionOperations.cs:line 673
   at Raven.Client.Documents.Session.InMemoryDocumentSessionOperations.StoreAsyncInternal(Object entity, String changeVector, String id, ConcurrencyCheckMode forceConcurrencyCheck, CancellationToken token) in C:\Builds\RavenDB-Stable-4.1\src\Raven.Client\Documents\Session\InMemoryDocumentSessionOperations.cs:line 703
   <Project Specific StackTrace>
   at lambda_method(Closure , Object )
   at Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable.Awaiter.GetResult()
   at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextExceptionFilterAsync()

Interestingly the application works perfectly fine in one of the very similar machine with identical set up and same set of framework installed. I'm not sure what is causing this Raven to fail. Any pointers is highly appreciated.

.net-core
ravendb
asp.net-core-2.1
asked on Stack Overflow Jan 31, 2019 by Ankit Vijay • edited Jan 31, 2019 by Ankit Vijay

2 Answers

1

Looks like System.Runtime.CompilerServices.Unsafe is not installed correctly.

Try:

1. Installing and using the latest RavenDB client package -OR-

2. Try to manually install from https://www.nuget.org/packages/System.Runtime.CompilerServices.Unsafe/

Install-Package System.Runtime.CompilerServices.Unsafe -Version 4.5.2
answered on Stack Overflow Jan 31, 2019 by Danielle
0

After fiddling around for more than day. I was able to reproduce the issue on my local machine with following setup:

  • No DOTNET Core SDK installed

  • Installed .NET Core Hosting and Runtime for .NET Core 2.1.3 and .NET Core 2.2.0

enter image description here

If I ALSO had .NET Core 2.1.6 Hosting and Runtime installed on my machine (with or without 2.1.3) the issue disappeared.

That made me to believe that .NET Core 2.1.6 installation on affected environment was somehow corrupt. So I uninstalled and reinstalled .NET Core 2.1.6 Hosting and Runtime, and this magically fixed issue.

However, this has now made our IT a bit nervous and jittery as they now feel Hosting and Runtimes cannot be trusted anymore. You literally are shooting in dark in such issues are encountered.

answered on Stack Overflow Feb 1, 2019 by Ankit Vijay • edited Feb 1, 2019 by Ankit Vijay

User contributions licensed under CC BY-SA 3.0