【问题标题】:RavenDB exception on query - Method not found: 'Void Raven.Abstractions.Data.IndexQuery.set_DefaultField(System.String)'RavenDB 查询异常 - 找不到方法:'Void Raven.Abstractions.Data.IndexQuery.set_DefaultField(System.String)'
【发布时间】:2012-07-01 03:20:45
【问题描述】:

我在刷新模型的 foreach 循环期间遇到以下异常,因为它尝试枚举查询检索到的结果。我无法在互联网上的其他任何地方找到与此错误相关的任何内容。有人可以指出我做错了什么吗?

System.MissingMethodException 未处理

Message=找不到方法:'Void Raven.Abstractions.Data.IndexQuery.set_DefaultField(System.String)'。 Source=Raven.Client.Lightweight

堆栈跟踪:

在 Raven.Client.Document.AbstractDocumentQuery`2.GenerateIndexQuery(字符串查询)

在 c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Document\AbstractDocumentQuery.cs:399 行中的 Raven.Client.Document.AbstractDocumentQuery2.InitializeQueryOperation(Action2 setOperationHeaders)

在 c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Document\AbstractDocumentQuery.cs:line 434 中的 Raven.Client.Document.AbstractDocumentQuery`2.InitSync() 处

在 c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Document\AbstractDocumentQuery.cs:line 421 中的 Raven.Client.Document.AbstractDocumentQuery`2.get_QueryResult()

在 c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Linq\RavenQueryProviderProcessor.cs:1263 行中的 Raven.Client.Linq.RavenQueryProviderProcessor`1.ExecuteQueryTProjection

在 c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Linq\RavenQueryProviderProcessor.cs:1244 行中的 Raven.Client.Linq.RavenQueryProviderProcessor`1.Execute(表达式表达式)

在 c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Linq\RavenQueryProvider.cs:138 行中的 Raven.Client.Linq.RavenQueryProvider`1.Execute(表达式表达式)

在 c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Linq\RavenQueryProvider.cs:line 195 中的 Raven.Client.Linq.RavenQueryProvider`1.System.Linq.IQueryProvider.Execute(表达式表达式)

在 c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Linq\RavenQueryInspector.cs:line 97 中的 Raven.Client.Linq.RavenQueryInspector`1.GetEnumerator()

在 C:\AdminPanel\AdminPanel.xaml.cs:line 111 中的 AdminPanel.RefreshModel() 处

private void RefreshModel()
{
    MainModel.Movies.Clear();
    foreach (FriendlyName movie in App.Database.QueryAllMovies())
    {
        MainModel.Movies.Add(movie);
    }
}

public IEnumerable<FriendlyName> QueryAllMovies()
{
    using (var session = DocumentStore.OpenSession())
    {
        return session.Query<Movie, Movies_AsFriendlyName>().As<FriendlyName>();
    }
}

class Movies_AsFriendlyName : AbstractIndexCreationTask<Movie>
{
    public Movies_AsFriendlyName()
    {
        Map = movies => movies.Select(movie => new { Id = movie.Id, Name = movie.FileName });

        TransformResults = (database, movies) => movies.Select(movie => new { Id = movie.Id, Name = movie.FileName });
    }
}

public class FriendlyName
{
    public string Name { get; set; }
    public string Id { get; set; }

    public FriendlyName(string id, string name)
    {
        Id = id;
        Name = name;
    }

    public override string ToString()
    {
        return Name;
    }
}

【问题讨论】:

    标签: c# ravendb


    【解决方案1】:

    通常当你有这样的东西时,你是针对一个版本编译的,但它试图使用的 dll 是另一个版本。

    我敢打赌,如果您查看程序运行位置和编译位置之间的版本,它们是不同的。

    【讨论】:

    • 我不确定我是否遵循。在 Visual Studio 中工作,我清理、构建然后运行。你是说不同版本的Raven吗?这是我用于 NuGet 的 packages.config:
    • 抱歉,我不熟悉 StackOverflow 评论的怪异之处。这就是我上面想说的。在我的 NuGet packages.config 文件中,RavenDB 使用 1.0.888,但也有 1.0.960 版本的 RavenDB.Embedded、RavenDB.Database 和 RavenDB.Client。我想在这个工作和停止工作之间发生了变化的一件事是除了那些其他依赖项之外还引入了嵌入式包。我没有做对吗?我试图让 App.config 中的值可以指定是使用嵌入式还是客户端 raven 实例。这可能吗?
    猜你喜欢
    • 2015-08-14
    • 2015-08-05
    • 2018-10-10
    • 1970-01-01
    • 1970-01-01
    • 2018-12-14
    • 2021-06-17
    • 1970-01-01
    • 2021-12-27
    相关资源
    最近更新 更多