我有一个使用NHUnspell NuGet包的ASP.NET/MVC Web角色。当我尝试运行它,我得到了以下错误消息:使用NHUnspell NuGet包时无法加载文件或程序集Hunspellx64.dll?
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目录中。
更新:感谢Thomas对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
这样做。在发生此错误之前,我已经成功使用NHUnspell。破坏的东西是用NuGet安装AttributeRouting。 AttributeRouting在旧版本的WebActivator(1.0.0.0)中拖动。不幸的是,当您执行更新操作时,NuGet不会建议更新它。您必须根据此网页的说明通过软件包管理器控制台手动执行更新:http://www.nuget。org/packages/WebActivator –
WebActivator已被弃用,以支持WebActivatorEx;希望有一些NuGet技巧可以让WebActivatorEx满足WebActivator的依赖性要求,或者每个需要它的人都转到WebActivatorEx –