SolrNet - 给定的键不在字典中 [英] SolrNet - The given key was not present in the dictionary

查看:536
本文介绍了SolrNet - 给定的键不在字典中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用SolbNet与vb.net 2.0,似乎不能实例化solr。



Dim solr As ISolrOperations(Of PMWProperty)= ServiceLocator.Current.GetInstance(Of PMWProperty)()



抛出异常:



[KeyNotFoundException:给定的键不在字典中。]
System.ThrowHelper.ThrowKeyNotFoundException()+28
System.Collections.Generic.Dictionary`2.get_Item(TKey key)+7456108
SolrNet.Utils.Container.DoGetInstance(键入serviceType,String key)+22
Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance (键入serviceType,String key)+47



[ActivationException:尝试获取类型PMWProperty,键的实例时激活错误]
Microsoft.Practices .ServiceLocation.ServiceLocatorImplBase.GetInstance(type serviceType,String key)+104
Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance()+5



我有一个类PMWProperty只有几个字段匹配我的solr模式。我可以通过solr url运行查询(localhost:8983 / solr),但是无法使其在代码中工作。



?例外似乎说关键是,但应该是什么呢?为什么我需要一个密钥?

解决方案

您需要获得 ISolrOperations(PMWProperty)从服务定位器,而不是 PMWProperty ,所以代码应该如下所示:

  Dim solr As ISolrOperations(Of PMWProperty)= ServiceLocator.Current.GetInstance(Of ISolrOperations(Of PMWProperty))()


I'm using SolrNet with vb.net 2.0 and can't seem to instantiate solr.

Dim solr As ISolrOperations(Of PMWProperty) = ServiceLocator.Current.GetInstance(Of PMWProperty)()

throws the exception:

[KeyNotFoundException: The given key was not present in the dictionary.] System.ThrowHelper.ThrowKeyNotFoundException() +28 System.Collections.Generic.Dictionary`2.get_Item(TKey key) +7456108 SolrNet.Utils.Container.DoGetInstance(Type serviceType, String key) +22 Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key) +47

[ActivationException: Activation error occured while trying to get instance of type PMWProperty, key ""] Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key) +104 Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance() +5

I have a class PMWProperty with only a few fields that match to my solr schema. I can run queries through the solr url just fine (localhost:8983/solr), but can't get it working in my code.

What key is it looking at? The exception seems to say that the key is "", but what should it be? Why do I need a key?

解决方案

You need to get ISolrOperations(Of PMWProperty) from the service locator, not PMWProperty, so the code should look like this:

Dim solr As ISolrOperations(Of PMWProperty) = ServiceLocator.Current.GetInstance(Of ISolrOperations(Of PMWProperty))()

这篇关于SolrNet - 给定的键不在字典中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆