EsentFileNotFoundException.FileNotFound exception during RavenDb-Embedded initialization

I get a very nasty error when calling Initialize in the class EmbeddableDocumentStore. This is a WPF application that tries to start or initialize a RavenDB database using c: \ temp \ ravenDb.

My code is:

EmbeddableDocumentStore _documentStore = new EmbeddableDocumentStore() { DataDirectory = @"C:\temp\RavenDb" }; using (_documentStore.Initialize()) { } 

Pretty simple. The error occurs when calling Initialize (). This is a complete error:

 Microsoft.Isam.Esent.Interop.EsentFileNotFoundException occurred Message=File not found Source=Esent.Interop StackTrace: at Microsoft.Isam.Esent.Interop.Api.Check(Int32 err) in C:\Work\ravendb\SharedLibs\Sources\managedesent-61618\EsentInterop\Api.cs:line 2736 InnerException: 

Which is disappointing, when I create a new WPF application and copy in the same code, it works correctly and can initialize and create basic files. Then, when I return to the main WPF application, now db can initialize (as the files are created), but any call to Session.Query results in the following error:

 System.IO.FileNotFoundException occurred Message=segments.gen Source=Lucene.Net StackTrace: at Lucene.Net.Store.RAMDirectory.OpenInput(String name) in z:\Libs\lucene.net\src\core\Store\RAMDirectory.cs:line 301 InnerException: 

Edit: Full code: He called the background worker delegate:

 private void RefreshGrid() { BackgroundWorker bw = new BackgroundWorker(); bw.DoWork += new DoWorkEventHandler(bw_DoWork); bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted); if (bw.IsBusy != true) { bw.RunWorkerAsync(_domainType); } } void bw_DoWork(object sender, DoWorkEventArgs e) { e.Result = EventStoreInstance.Instance.GetAggregateRoots((Type)e.Argument); } 

Which then calls GetAggregateRoots:

 //Called in class ctor: _publisher = publisher; _documentStore = new EmbeddableDocumentStore() { DataDirectory = _dataDir // is "C:\temp\RavenDb" }; public List<AggregateRootModel> GetAggregateRoots(Type AggregrateRootType) { using (_documentStore.Initialize()) { using (var session = _documentStore.OpenSession()) { var aggregateRoots = session.Query<AggregateRootModel>() .Where(p => p.Type == AggregrateRootType.AssemblyQualifiedName).ToList(); return aggregateRoots; } } } 
+4
source share
1 answer

They are expected to be handled internally by RavenDB. You see them because you are working in a debugger and stop on any exceptions.

+7
source

Source: https://habr.com/ru/post/1391692/


All Articles