【问题标题】:Unable to connect RavenDB Cloud, in Microservice (AWS Lambda)无法在微服务 (AWS Lambda) 中连接 RavenDB 云
【发布时间】:2019-08-25 05:08:09
【问题描述】:

问题陈述

我的一个 POC 尝试使用 AWS Lambda 函数连接 RavenDB 云服务,但连接失败。

背景

我为此使用客户端证书 (.pfx) 文件。它在使用 X509Certificate2 分配证书期间准确地引发错误。我已将证书转换为 byte[] 并通过。我使用的证书可以完全访问数据库。我包含以下错误

代码


            if (_bClientCertificate != null)
            {
                if (_bClientCertificate.Length > 0)
                {
                    xclientCertificate = new X509Certificate2(_bClientCertificate);
                }
            }

             IDocumentStore store = new DocumentStore()
            {
                Certificate = xclientCertificate, //Error occured here

                Urls = _Urls,
                Database = _DBName
            }.Initialize();

异常详情:

System.IO.FileLoadException
  HResult=0x80131509
  Message=Could not load file or assembly 'Sparrow, Version=4.2.2.0, Culture=neutral, PublicKeyToken=37f41c7f99471593'. An operation is not legal in the current state. (Exception from HRESULT: 0x80131509)
  Source=Raven.Client
  StackTrace:
   at Raven.Client.Documents.Subscriptions.DocumentSubscriptions..ctor(IDocumentStore store) in C:\Builds\RavenDB-Stable-4.2\42017\src\Raven.Client\Documents\Subscriptions\DocumentSubscriptions.cs:line 33
   at Raven.Client.Documents.DocumentStoreBase..ctor() in C:\Builds\RavenDB-Stable-4.2\42017\src\Raven.Client\Documents\DocumentStoreBase.cs:line 28
   at Firecloud.DataAccess.RavenDB.SessionStore.CreateStore() in C:\Works\SourceCode\FC\Library\RavenDB\FC.DataAccess.Raven\SessionStore.cs:line 87
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)

【问题讨论】:

  • 你有安装包麻雀吗?
  • 没有。我只安装了 RavenDB 客户端包。
  • 尝试安装这个包。一旦我在运行时遇到了 raven 包丢失的类似问题,手动安装解决了这个问题
  • 我不确定这个包。你能告诉我Nuget包的网址吗?
  • 嗯,sparrow 似乎是 raven 的一部分,您是否尝试安装较旧的 ravendb 版本?

标签: c# microservices ravendb


【解决方案1】:

我以前也遇到过这个问题,显然一些可视化 C++ 库可能会丢失。 尝试安装Visual C++ Redistributable for Visual Studio 2015.

【讨论】:

  • 你的项目中有这个dll吗? RavenDB.Client.4.2.1\lib\netstandard2.0\Sparrow.dll 如果没有,请尝试重新安装 RavenDB 客户端。
  • 我做到了。相同的代码适用于 API 项目。但不在 AWS Lambda 函数中。
猜你喜欢
  • 2020-03-02
  • 2015-10-29
  • 1970-01-01
  • 2021-07-21
  • 1970-01-01
  • 2022-11-25
  • 2018-08-02
  • 1970-01-01
  • 2021-10-07
相关资源
最近更新 更多