【发布时间】:2016-07-14 09:34:27
【问题描述】:
我正在用 NCrawler 做一些测试,得到了这个奇怪的异常:
“NCrawler.NCrawlerModule”的类型初始化程序引发了异常。 内部异常是:找不到方法:'无效 Autofac.RegistrationExtensions.RegisterModule(Autofac.ContainerBuilder, Autofac.Core.IModule)'。
异常发生在 Crawlers 构造函数中。
这是我的代码:
static void Main(string[] args)
{
using (Crawler c = new Crawler(new Uri("http://stackoverflow.com"), new HtmlDocumentProcessor(), new TestStep()))
{
c.MaximumThreadCount = 3;
c.MaximumCrawlDepth = 2;
c.ExcludeFilter = new[] { new RegexFilter(
new Regex(@"(\.jpg|\.css|\.js|\.gif|\.jpeg|\.png|\.ico)",
RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.IgnoreCase)) };
c.Crawl();
}
}
这是 TestStep 类:
public class TestStep : IPipelineStep
{
public void Process(Crawler crawler, PropertyBag propertyBag)
{
Console.Out.WriteLineAsync(propertyBag.Step.Uri.ToString());
}
}
我尝试使用 NuGet 卸载并重新安装 Autofac,但没有成功。
奇怪的是 packages.config 上的版本是 3.5.2 但在 app.config 上似乎试图将其绑定到 3.5.0
这是 packages.config 中的 AutoFac:
<package id="Autofac" version="3.5.2" targetFramework="net452" />
在 app.config 中:
<dependentAssembly>
<assemblyIdentity name="Autofac" publicKeyToken="17863af14b0044da" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.5.0.0" newVersion="3.5.0.0" />
</dependentAssembly>
有人可以帮忙吗?
【问题讨论】:
标签: c# .net web-crawler console-application autofac