SolrNet - 字典中不存在给定的键
我将 SolrNet 与 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(类型服务类型,字符串键)+22 Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key) +47
[ActivationException: 尝试获取类型 PMWProperty、键“”的实例时发生激活错误] Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(类型服务类型,字符串键)+104 Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance() +5
我有一个 PMWProperty 类,其中只有几个与我的 solr 架构匹配的字段。我可以通过 solr url 运行查询(localhost:8983/solr),但无法在我的代码中运行。
它在看什么键?异常似乎说关键是“”,但是应该是什么?为什么我需要钥匙?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要从服务定位器获取
ISolrOperations(Of PMWProperty)
,而不是PMWProperty
,因此代码应如下所示:You need to get
ISolrOperations(Of PMWProperty)
from the service locator, notPMWProperty
, so the code should look like this: