SolrNet - 字典中不存在给定的键

发布于 2024-10-13 05:47:13 字数 890 浏览 5 评论 0原文

我将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

天赋异禀 2024-10-20 05:47:13

您需要从服务定位器获取 ISolrOperations(Of PMWProperty),而不是 PMWProperty,因此代码应如下所示:

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

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))()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文