RavenDB 内存数据库错误:找不到方法:'Raven.Json.Linq.RavenJObject

发布于 2024-12-14 20:49:07 字数 3529 浏览 0 评论 0原文

我在使用 RavenDB 设置内存数据库时遇到问题。

我得到的错误是: 我得到的是: 设置:System.MissingMethodException:找不到方法:'Raven.Json.Linq.RavenJObject Raven.Abstractions.Extensions.JsonExtensions.ToJObject(Byte[])'

完整错误跟踪:

SetUp : System.MissingMethodException :
    Method not found: 'Raven.Json.Linq.RavenJObject Raven.Abstractions.Extensions.JsonExtensions.ToJObject(Byte[])'. 
at Raven.Storage.Managed.DocumentsStorageActions.DeleteDocument(String key, Nullable1 etag, ref RavenJObject metadata) 
at Raven.Database.DocumentDatabase.<>c__DisplayClass4e.<Delete>b__48(IStorageActionsAccessor actions)
    in c:\Builds\raven\Raven.Database\DocumentDatabase.cs: line 518 
at Raven.Storage.Managed.TransactionalStorage.Batch(Action1 action)
    in c:\Builds\raven\Raven.Storage.Managed\TransactionalStorage.cs: line 112 
at Raven.Database.DocumentDatabase.Delete(String key, Nullable`1 etag, TransactionInformation transactionInformation)
    in c:\Builds\raven\Raven.Database\DocumentDatabase.cs: line 509
at Raven.Database.Backup.RemoveBackupDocumentStartupTask.Execute(DocumentDatabase database)
    in c:\Builds\raven\Raven.Database\Backup\RemoveBackupDocumentStartupTask.cs: line 17 
at Raven.Database.DocumentDatabase.ExecuteStartupTasks()
    in c:\Builds\raven\Raven.Database\DocumentDatabase.cs: line 214 
at Raven.Database.DocumentDatabase..ctor(InMemoryRavenConfiguration configuration)
    in c:\Builds\raven\Raven.Database\DocumentDatabase.cs: line 173 
at Raven.Client.Embedded.EmbeddableDocumentStore.InitializeInternal() 
at Raven.Client.Document.DocumentStore.Initialize()
    in c:\Builds\raven\Raven.Client.Lightweight\Document\DocumentStore.cs: line 484 
at Aqueduct.Dashboard.Web.Tests.RavenInMemoryDatabase.InMemoryDatabase.DocumentStore()
    in InMemoryDatabase.cs: line 27 
at Aqueduct.Dashboard.Web.Tests.MonitoringServiceTests.Setup()
    in MonitoringServiceTests.cs: line 24

我的内存数据库定义如下:

public EmbeddableDocumentStore DocumentStore()
    {

        string path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(InMemoryDatabase)).CodeBase);
        path = Path.Combine(path, "testing").Substring(6);

        var documentStore = new EmbeddableDocumentStore()
        {
            Configuration =
            {
                DataDirectory = path,
                RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true,
                DefaultStorageTypeName = "munin",
                RunInMemory = true
            }
        };

        documentStore.Initialize();

        new RavenDocumentsByEntityName().Execute(documentStore);

        return documentStore;
    }

我的测试是:

 [TestFixture]
public class MonitoringServiceTests
{
    private IMonitoringService m_monitoringService;
    private PerformanceRepository m_performanceRepository;
    private InMemoryDatabase m_inMemoryDatabase;

    [TestFixtureSetUp]
    public void Setup()
    {
        m_inMemoryDatabase = new InMemoryDatabase();

        m_performanceRepository = new PerformanceRepository(m_inMemoryDatabase.DocumentStore().OpenSession());
        m_monitoringService = new MonitoringService(m_performanceRepository);
    }

    [Test]
    public void RecordSnapShot_RecordsCpuUsage()
    {
        m_monitoringService.RecordSnapShot();
        var allMeasurements = m_performanceRepository.GetAll();
        Assert.IsTrue(allMeasurements.Where(x => x.MeasurementType == MeasurementType.ProcessorUsage).Count() == 1);
    }
}

Im having Trouble setting up an in memory database using RavenDB.

The error I get is: I get is:
SetUp : System.MissingMethodException : Method not found: 'Raven.Json.Linq.RavenJObject Raven.Abstractions.Extensions.JsonExtensions.ToJObject(Byte[])'

Full Error Trace:

SetUp : System.MissingMethodException :
    Method not found: 'Raven.Json.Linq.RavenJObject Raven.Abstractions.Extensions.JsonExtensions.ToJObject(Byte[])'. 
at Raven.Storage.Managed.DocumentsStorageActions.DeleteDocument(String key, Nullable1 etag, ref RavenJObject metadata) 
at Raven.Database.DocumentDatabase.<>c__DisplayClass4e.<Delete>b__48(IStorageActionsAccessor actions)
    in c:\Builds\raven\Raven.Database\DocumentDatabase.cs: line 518 
at Raven.Storage.Managed.TransactionalStorage.Batch(Action1 action)
    in c:\Builds\raven\Raven.Storage.Managed\TransactionalStorage.cs: line 112 
at Raven.Database.DocumentDatabase.Delete(String key, Nullable`1 etag, TransactionInformation transactionInformation)
    in c:\Builds\raven\Raven.Database\DocumentDatabase.cs: line 509
at Raven.Database.Backup.RemoveBackupDocumentStartupTask.Execute(DocumentDatabase database)
    in c:\Builds\raven\Raven.Database\Backup\RemoveBackupDocumentStartupTask.cs: line 17 
at Raven.Database.DocumentDatabase.ExecuteStartupTasks()
    in c:\Builds\raven\Raven.Database\DocumentDatabase.cs: line 214 
at Raven.Database.DocumentDatabase..ctor(InMemoryRavenConfiguration configuration)
    in c:\Builds\raven\Raven.Database\DocumentDatabase.cs: line 173 
at Raven.Client.Embedded.EmbeddableDocumentStore.InitializeInternal() 
at Raven.Client.Document.DocumentStore.Initialize()
    in c:\Builds\raven\Raven.Client.Lightweight\Document\DocumentStore.cs: line 484 
at Aqueduct.Dashboard.Web.Tests.RavenInMemoryDatabase.InMemoryDatabase.DocumentStore()
    in InMemoryDatabase.cs: line 27 
at Aqueduct.Dashboard.Web.Tests.MonitoringServiceTests.Setup()
    in MonitoringServiceTests.cs: line 24

My InMemory db is defined below:

public EmbeddableDocumentStore DocumentStore()
    {

        string path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(InMemoryDatabase)).CodeBase);
        path = Path.Combine(path, "testing").Substring(6);

        var documentStore = new EmbeddableDocumentStore()
        {
            Configuration =
            {
                DataDirectory = path,
                RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true,
                DefaultStorageTypeName = "munin",
                RunInMemory = true
            }
        };

        documentStore.Initialize();

        new RavenDocumentsByEntityName().Execute(documentStore);

        return documentStore;
    }

My Test is:

 [TestFixture]
public class MonitoringServiceTests
{
    private IMonitoringService m_monitoringService;
    private PerformanceRepository m_performanceRepository;
    private InMemoryDatabase m_inMemoryDatabase;

    [TestFixtureSetUp]
    public void Setup()
    {
        m_inMemoryDatabase = new InMemoryDatabase();

        m_performanceRepository = new PerformanceRepository(m_inMemoryDatabase.DocumentStore().OpenSession());
        m_monitoringService = new MonitoringService(m_performanceRepository);
    }

    [Test]
    public void RecordSnapShot_RecordsCpuUsage()
    {
        m_monitoringService.RecordSnapShot();
        var allMeasurements = m_performanceRepository.GetAll();
        Assert.IsTrue(allMeasurements.Where(x => x.MeasurementType == MeasurementType.ProcessorUsage).Count() == 1);
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

提笔书几行 2024-12-21 20:49:07

您可能有混合版本的 ravendb dll,这是唯一可能导致此错误的原因

You probably have mixed versions of the ravendb dlls, that is the only thing that can cause this error

惟欲睡 2024-12-21 20:49:07

documentStore 的创建更改为以下内容,看看是否有效:

var documentStore = new EmbeddableDocumentStore { RunInMemory = true }

据我所知,您在创建商店时做了一些非常奇怪的事情。当你想在内存中运行时为什么要提供路径?即使路径可以是相对的并且可以是简单的“数据”。

查看 ravens 源代码,(希望)看到许多使用内存存储的工作测试。

Change the creation of the documentStore to the following and see if that works:

var documentStore = new EmbeddableDocumentStore { RunInMemory = true }

As far as I see you're doing some really weird stuff when creating your store. Why do you want to supply a path when you want to run in memory? Even if, the path can be relative and something simple as "Data".

Check out ravens source code to see (hopefully) many working tests using in-memory storage.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文