.net-core - 保存到 Raven 时出现异常
问题描述
在我们的一个环境中尝试将实体保存到 Raven 时出现异常。
以下是详细信息:
应用程序目标框架:.NET Core 2.1
RavenDB.Client 版本:4.1.2
.Net Core Runtime and Hosting Bundle 安装在服务器上:
2.0.5
2.1.3
2.1.6
2.2.0
(我们安装了多个版本,因为它是一个托管多个应用程序的共享环境)
例外:
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()
有趣的是,该应用程序在一台非常相似的机器上运行得非常好,并且安装了相同的设置和相同的框架集。我不确定是什么导致这只 Raven 失败。任何指针都受到高度赞赏。
解决方案
看起来System.Runtime.CompilerServices.Unsafe没有正确安装。
尝试:
1. 安装和使用最新的 RavenDB 客户端包- 或 -
2. 尝试从
https://www.nuget.org/packages/System.Runtime.CompilerServices.Unsafe/手动安装
Install-Package System.Runtime.CompilerServices.Unsafe -Version 4.5.2
推荐阅读
- android - 如何在 Kotlin 中传递可选参数 LocalTime
- sql - Vertica SQL - 将排名号转换为自己的列
- html - (引导网格 col-md-4)对齐不起作用
- python - 如何在 python 中为不和谐的机器人制作踢命令
- c++ - ImmGetContext 总是返回零
- python - 更新关于字段 django 的模型
- intellij-idea - 错误运行场景请正确指定包:“../null”文件未找到 - Cucumber/CodeceptJs/IntelliJ
- google-sheets - 如何检查列中是否存在某个票证?
- node.js - 测试执行后如何退出 Mocha?
- google-sheets - 在数组公式中使用下拉列表 - Google 表格