我目前正在使用NEST 5.0.0-rc3,但无法运行任何查询。
例如,此查询:
var client = new Nest.ElasticClient(connectionSettings);
var searchResponse = client.Search<Page>(s => s
.MatchAll()
.From(0)
.Size(10)
.Source(f => f.Includes(i => i.Field(x => x.Id)))
);
生成以下.net异常(对不起的格式有点粗糙):
<Error>
<Message>An error has occurred.</Message>
<ExceptionMessage>
Could not load file or assembly 'Nest, Version=2.0.0.0, Culture=neutral, PublicKeyToken=96c599bbe3e70f5d' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
</ExceptionMessage>
<ExceptionType>System.IO.FileLoadException</ExceptionType>
<StackTrace>
at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) at System.Reflection.CustomAttribute.IsCustomAttributeDefined(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Int32 attributeCtorToken, Boolean mustBeInheritable) at System.Reflection.CustomAttribute.IsDefined(RuntimePropertyInfo property, RuntimeType caType) at System.Reflection.RuntimePropertyInfo.IsDefined(Type attributeType, Boolean inherit) at Newtonsoft.Json.Serialization.DefaultContractResolver.GetSerializableMembers(Type objectType) at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateProperties(Type type, MemberSerialization memberSerialization) at Nest.ElasticContractResolver.CreateProperties(Type type, MemberSerialization memberSerialization) in C:\Users\russ\source\elasticsearch-net-5.x\src\Nest\CommonAbstractions\SerializationBehavior\ElasticContractResolver.cs:line 119 at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateObjectContract(Type objectType) at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract(Type objectType) at Nest.ElasticContractResolver.<CreateContract>b__12_0(Type o) in C:\Users\russ\source\elasticsearch-net-5.x\src\Nest\CommonAbstractions\SerializationBehavior\ElasticContractResolver.cs:line 41 at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) at Nest.ElasticContractResolver.CreateContract(Type objectType) in C:\Users\russ\source\elasticsearch-net-5.x\src\Nest\CommonAbstractions\SerializationBehavior\ElasticContractResolver.cs:line 39 at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract(Type type) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.GetContractSafe(Type type) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Populate(JsonReader reader, Object target) at Newtonsoft.Json.Serialization.JsonSerializerProxy.PopulateInternal(JsonReader reader, Object target) at Newtonsoft.Json.JsonSerializer.Populate(JsonReader reader, Object target) at Nest.ConcreteTypeConverter`1.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer) in C:\Users\russ\source\elasticsearch-net-5.x\src\Nest\CommonAbstractions\SerializationBehavior\StatefulDeserialization\ConcreteTypeConverter.cs:line 67 at Nest.DefaultHitJsonConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer) in C:\Users\russ\source\elasticsearch-net-5.x\src\Nest\CommonAbstractions\SerializationBehavior\StatefulDeserialization\ConcreteTypeConverter.cs:line 32 at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType) at Nest.JsonNetSerializer.Deserialize[T](Stream stream) in C:\Users\russ\source\elasticsearch-net-5.x\src\Nest\CommonAbstractions\SerializationBehavior\JsonNetSerializer.cs:line 114 at Elasticsearch.Net.ResponseBuilder`1.SetBody(ElasticsearchResponse`1 response, Stream stream) in C:\Users\russ\source\elasticsearch-net-5.x\src\Elasticsearch.Net\Transport\Pipeline\ResponseBuilder.cs:line 79 at Elasticsearch.Net.ResponseBuilder`1.ToResponse() in C:\Users\russ\source\elasticsearch-net-5.x\src\Elasticsearch.Net\Transport\Pipeline\ResponseBuilder.cs:line 33 at Elasticsearch.Net.HttpConnection.Request[TReturn](RequestData requestData) in C:\Users\russ\source\elasticsearch-net-5.x\src\Elasticsearch.Net\Connection\HttpConnection.cs:line 155 at Elasticsearch.Net.RequestPipeline.CallElasticsearch[TReturn](RequestData requestData) in C:\Users\russ\source\elasticsearch-net-5.x\src\Elasticsearch.Net\Transport\Pipeline\RequestPipeline.cs:line 411 at Elasticsearch.Net.Transport`1.Request[TReturn](HttpMethod method, String path, PostData`1 data, IRequestParameters requestParameters) in C:\Users\russ\source\elasticsearch-net-5.x\src\Elasticsearch.Net\Transport\Transport.cs:line 69
</StackTrace>
</Error>
我是否/还应该引用对Nest的2.x版本的引用?
最佳答案
NEST 5.x不依赖NEST 2.x;这听起来像是您针对/引用NEST 2.x进行了其他编译,也应该针对5.x进行了引用/编译。
关于c# - NEST 5.x是否依赖于NEST 2.x?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40869313/