嵌入式RavenDB“无法找到事务存储类型”错误

时间:2011-03-29 23:30:29

标签: c# nosql embedding ravendb document-database

我能够根据以下代码找到RavenDB的简单测试:http://ravendb.net/tutorials/hello-world

接下来我尝试以嵌入式方式运行它,但我继续收到以下错误:

Message: Could not find transactional storage type: Raven.Storage.Esent.TransactionalStorage, Raven.Storage.Esent  
StackTrace:    at Raven.Database.Config.InMemoryRavenConfiguration.CreateTransactionalStorage(Action notifyAboutWork) in c:\Builds\raven\Raven.Database\Config\InMemoryRavenConfiguration.cs:line 272
   at Raven.Database.DocumentDatabase..ctor(InMemoryRavenConfiguration configuration) in c:\Builds\raven\Raven.Database\DocumentDatabase.cs:line 109
   at Raven.Client.Client.EmbeddableDocumentStore.InitializeInternal() in c:\Builds\raven\Raven.Client.Embedded\EmbeddableDocumentStore.cs:line 130
   at Raven.Client.Document.DocumentStore.Initialize() in c:\Builds\raven\Raven.Client.Lightweight\Document\DocumentStore.cs:line 388
   at Tests.RavenEmbedded.RavenDB..ctor() in C:\Users\Pranav\Documents\Projects\Repositories-Clone\Common-clone\Tests\RavenDB.cs:line 114
   at Tests.TestRavenDB.Basics() in C:\Users\Pranav\Documents\Projects\Repositories-Clone\Common-clone\Tests\RavenDB.cs:line 170 

设置:

目标框架是 .NET Framework 4

我在项目中添加了以下参考资料:

  1. \ RavenDB - 建造-309 \ EmbeddedClient \ Raven.Client.Embedded.dll
  2. \ RavenDB - 建造-309 \客户端\ Raven.Client.Lightweight.dll
  3. \ RavenDB - 建造-309 \ EmbeddedClient \ Raven.Storage.Esent.dll
  4. \ RavenDB - 建造-309 \ EmbeddedClient \ Raven.Storage.Managed.dll

  5. 代码为:

    namespace Tests.RavenEmbedded
    {
        using Raven.Client.Client;
        using Raven.Client.Document;
        using Raven.Storage.Esent;
        using Raven.Storage.Managed;
        using Tests.RavenData;
    
        class RavenDB
        {
            public RavenDB()
            {
                // EmbeddableDocumentStore store = new EmbeddableDocumentStore { DataDirectory = @"C:\Temp\RavenData" };
                //Raven.Storage.Esent.TransactionalStorage
                var store = new EmbeddableDocumentStore  { DataDirectory = @"C:\Temp\RavenData" };
                store.Initialize();
    
                #region Write Data
                using (var session = store.OpenSession())
                {
                    var product = new Product
                    {
                        Cost = 3.99m,
                        Name = "Milk",
                    };
                    session.Store(product);
                    session.SaveChanges();
    
                    session.Store(new Order
                    {
                        Customer = "customers/ayende",
                        OrderLines =
                          {
                              new OrderLine
                              {
                                  ProductId = product.Id,
                                  Quantity = 3
                              },
                          }
                    });
                    session.SaveChanges();
                }
                #endregion
    
                #region Read Data
                using (var session = store.OpenSession())
                {
                    var order = session.Load("orders/1");
                    Debug.Print("Customer: {0}", order.Customer);
                    foreach (var orderLine in order.OrderLines)
                    {
                        Debug.Print("Product: {0} x {1}", orderLine.ProductId, orderLine.Quantity);
                    }
                    session.SaveChanges();
                }
    
                #endregion
    
            }
        }
    }
    
    namespace Tests
    {
        public class TestRavenDB
        {
            public static void Basics()
            {
                try
                {
                    //var db = new RavenClientServer.RavenDB();
                    var db = new RavenEmbedded.RavenDB();
                }
                catch (Exception ex)
                {
    
                    Debug.Print("Message: {0} ",ex.Message);
                    Debug.Print("StackTrace: {0} ",ex.StackTrace);
    
                }
            }
    
        }
    }
    

    我已经尝试了几天的搜索,并尝试了一些不同的变化。我不确定发生了什么。

2 个答案:

答案 0 :(得分:16)

感谢关于groups.google.com/group/ravendb/topics的Ayende Rahien。

解决方案是将“Raven.Storage.Esent”引用添加到主项目中。这是Visual Studio和间接引用的问题。

感谢@Derek建议我发布那里。

- Pranav

答案 1 :(得分:5)

您需要添加对Raven.Storage.Esent.dll

的引用