【发布时间】:2021-07-15 05:29:11
【问题描述】:
我已将一系列 ElasticSearch Nest 代码集成到我们自己的解决方案文件中。在我这样做之前,我首先在一个单独的解决方案中对其进行了测试。在我的单独解决方案中,一切正常。
异常详情如下:
Elasticsearch.Net.UnexpectedElasticsearchClientException: The type initializer for 'Nest.JsonNetSerializer.Converters.HandleNestTypesOnSourceJsonConverter' threw an exception.
在检查调试消息后,我得到了更多详细信息。
System.TypeLoadException: Could not load type 'Nest.CartesianPoint' from assembly 'Nest, Version=7.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxx'.
at Nest.JsonNetSerializer.Converters.HandleNestTypesOnSourceJsonConverter..cctor()
我一直在谷歌搜索,但找不到具体的答案。我所能找到的只是我的问题与此有关,因为在我单独的测试代码中我没有任何异常 - Could not load type from assembly error
为了提供一些细节,这就是我创建客户端的方式。
private ElasticClient GetClient()
{
var pool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
var connectionSettings = new ConnectionSettings(pool, (builtin, settings) =>
new JsonNetSerializer(builtin, settings, () =>
new JsonSerializerSettings {
TypeNameHandling = TypeNameHandling.All,
NullValueHandling = NullValueHandling.Include
}
)).DefaultIndex(DefaultIndex);
return new ElasticClient(connectionSettings);
}
现在我正在使用这个解决方案 - Could not load type from assembly error 查看我们的解决方案文件 - 考虑解决这个问题。
我希望有人以前可能遇到过这种情况。
提前致谢。
【问题讨论】:
标签: elasticsearch nest