我有一个使用 NHUnspell NuGet 包的 ASP.NET/MVC Web 角色。当我尝试运行它时,我收到以下错误消息:
Could not load file or assembly 'Hunspellx64.dll' or one of its dependencies. The module was expected to contain an assembly manifest.
这很奇怪,因为据我所知,我的 Web 角色项目根本不应该尝试加载非托管 Hunspellx64.dll。这应该由托管的 NHUnspell DLL 处理。该 DLL 作为构建步骤复制到 Web 角色的 /bin 目录。
更新: 感谢托马斯关于 WebActivator 已过时的评论,我能够解决这个问题。我将我的回复评论复制到他接受的答案中,以确保有此问题的其他人看到修复:
在此错误开始发生之前,我让 NHUnspell 成功运行。打破常规的是使用 NuGet 安装 AttributeRouting。AttributeRouting 拖入了旧版本的 WebActivator (1.0.0.0)。不幸的是,当您执行更新操作时,NuGet 不建议对其进行更新。您必须按照此网页的说明通过包管理器控制台手动进行更新:
这是收到修复之前的原始帖子的其余部分:
我已经在我的项目中搜索了对 Hunspellx64.dll 的直接引用/链接,包括我的 NuGet 包配置、packages.config、web.config、我的引用列表、原始项目文件等。我找不到对该 DLL 的任何直接引用. 我还能在哪里查看,或者我还能尝试阻止我的项目尝试直接加载该非托管 DLL 吗?这是 ASP.NET 错误转储:
[BadImageFormatException: Could not load file or assembly 'Hunspellx64.dll' or one of its dependencies. The module was expected to contain an assembly manifest.]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +34
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152
System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark) +102
System.Reflection.Assembly.LoadFrom(String assemblyFile) +34
WebActivator.PreApplicationStartCode.Start() in D:\Code\Bitbucket\WebActivator\WebActivator\PreApplicationStartCode.cs:11
[InvalidOperationException: The pre-application start initialization method Start on type WebActivator.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'Hunspellx64.dll' or one of its dependencies. The module was expected to contain an assembly manifest..]
System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +550
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +132
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath) +90
System.Web.Compilation.BuildManager.ExecutePreAppStart() +135
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +516
[HttpException (0x80004005): The pre-application start initialization method Start on type WebActivator.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'Hunspellx64.dll' or one of its dependencies. The module was expected to contain an assembly manifest..]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9874568
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254