c# - 该模块应包含程序集 list

标签 c# badimageformatexception

我有一个使用 C++ 库和一些 dll 的 C# 项目。当我运行它时,它运行良好。

库是 Awesomium ,包含 c++ 库和 c# 包装器

当我从我的 ASP.NET MVC 4 项目创建对此项目的引用时,我收到以下错误:

异常详细信息:System.BadImageFormatException:无法加载文件或程序集“file:///D:\Projects\Development\ProGamers\GamingSite\bin\avcodec-52.dll”或其依赖项之一。该模块应包含程序集 list 。

我尝试过的事情:

  1. 复制dll,还是不行(文件存在)。

  2. 在 GAC 中注册它,但我在那里遇到了同样的错误。

  3. 确保使用 .NET Framework 4.0(而不是客户端配置文件)

  4. 2 files with the same dll/exe name causing conflict - 我没有。

  5. Change the platform of the solution 到 AnyCPU/混合平台。

堆栈跟踪:

[BadImageFormatException: Could not load file or assembly 'file:///D:\Projects\Development\ProGamers\GamingSite\bin\avcodec-52.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.ActivationManager.Run() +190

[InvalidOperationException: The pre-application start initialization method Run on type WebActivator.ActivationManager threw an exception with the following error message: Could not load file or assembly 'file:///D:\Projects\Development\ProGamers\GamingSite\bin\avcodec-52.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 Run on type WebActivator.ActivationManager threw an exception with the following error message: Could not load file or assembly 'file:///D:\Projects\Development\ProGamers\GamingSite\bin\avcodec-52.dll' or one of its dependencies. The module was expected to contain an assembly manifest..]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9850940
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
   System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +456

最佳答案

我发现,我使用的 InstallUtil 与我的目标 .NET Framework 不同。我正在构建 .NET Framework 4.5,同时如果我使用 .NET Framework 2.0 版本会发生错误。为我的目标 .NET Framework 使用正确的 InstallUtil,解决了这个问题!

关于c# - 该模块应包含程序集 list ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12226676/

相关文章:

reporting-services - 32 位 Oracle 客户端的 SSRS 报告无法在 64 位环境中工作

64-bit - x64 上的 IIS 中的 BadImageFormatException

C# 9 可空类型问题

c# - 为什么我必须执行转换为值元组内的对象?

c# - 如何获取 LINQPad 到 Dump() System.__ComObject 引用?

c# - System.BadImageFormatException 未处理 - 简单修复

c# - Xamarin Android 的 FirebaseInstanceId.Instance.Token 抛出错误而不是返回 FCM token

c# - 应用程序在 Dispatcher.Invoke 后卡住

.net - 是否可以从为 'Any CPU' 编译为 64 位代码运行的 .NET 应用程序调用 64 位 native C++ DLL 文件?