Sitecore Autofac - 无效 Autofac.RegistrationExtensions.RegisterModule

Sitecore Autofac - Void Autofac.RegistrationExtensions.RegisterModule

我想在我的带有 Solr 的 Sitecore 项目中使用 Autofac, 我已将下一个代码设置为 global.asax

<%@Application Language='C#' Inherits="Sitecore.ContentSearch.SolrProvider.AutoFacIntegration.AutoFacApplication" %>

但我看到一个错误

Method not found: 'Void Autofac.RegistrationExtensions.RegisterModule(Autofac.ContainerBuilder, Autofac.Core.IModule)'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.MissingMethodException: Method not found: 'Void Autofac.RegistrationExtensions.RegisterModule(Autofac.ContainerBuilder, Autofac.Core.IModule)'

我检查了 AutoFac 版本,它是正确的 3.5.2,就像 Sitecore.ContentSearch.SolrProvider.AutoFacIntegration

我应该怎么做才能正确设置 Sitecore。

您是否删除了所有 Lucene 配置文件并添加了 App_Config/Include 中的所有 solr 配置文件。

您还需要放入所有 Solr Dll,如下所示。

出现此问题是因为 Sitecore 的 Solr 支持包依赖于旧的 Autofac 版本(3.1.5 或更早版本),其中方法 builder.RegisterModule() 仍在 Autofac.RegistrationExtensions 中定义。较新的 Autofac 版本在 class Autofac.ModuleRegistrationExtensions.

中定义了类似的方法

如果 Sitecore 不重新编译 Solr/Autofac 集成 dll,不幸的是,只有两种解决方法:

  1. 使用另一个 DI 库;
  2. 编写您自己的 Solr/Autofac 集成。

这个问题仍然存在于 Sitecore 8.2 附带的 Solr 支持包中。

我已向 Sitecore 支持部门注册此问题。

编辑: Sitecore 回复说希望支持 Autofac 3.2 及更高版本。要跟踪此请求的状态,您可以使用参考号 94626.