在EmbeddableDocumentStore类上调用Initialize时,我遇到了一个非常令人沮丧的错误。这是一个尝试在c:\ temp \ ravenDb启动或初始化RavenDB数据库的WPF应用程序。
我的代码是:
EmbeddableDocumentStore _documentStore = new EmbeddableDocumentStore()
{
DataDirectory = @"C:\temp\RavenDb"
};
using (_documentStore.Initialize())
{
}
相当简单。在调用Initialize()时发生错误。这是完整的错误:
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:
令人沮丧的是,当我创建一个新的WPF应用程序并使用相同的代码进行复制时,它可以正常工作,并且能够初始化和创建基本文件。然后,当我回到我的主WPF应用程序时 - 数据库现在能够初始化(因为文件已经创建),但任何Session.Query调用都会导致以下错误:
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:
编辑: 完整代码: 它是从后台工作者代表调用的:
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);
}
然后调用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;
}
}
}
答案 0 :(得分:7)
这些是预期的,它们在RavenDB内部处理。您正在看到它们,因为您正在调试器中运行并停止任何异常。