我有一個項目在C#中使用C++庫和一些DLL。當我運行它的時候效果很好。該模塊預計包含程序集清單
圖書館是Awesomium,同時包含C++庫和C#包裝
當我創建引用從我的ASP.NET MVC 4項目這個項目中,我得到以下錯誤:
異常詳細信息: System.BadImageFormatException:無法加載文件或程序集'file:/// D:\ Projects \ Development \ ProGamers \ GamingSite \ bin \ avcodec-52.dll'或其某個依賴項。預計該模塊將包含程序集清單。
事情我已經嘗試:
應對的dll文件,但它仍然無法正常工作(該文件存在)。
在GAC中註冊它,但我在那裏有同樣的錯誤。
確保使用.NET Framework 4.0(而不是客戶端配置文件)
Change the platform of the solution to AnyCPU/Mixed Platforms。
堆棧跟蹤:
[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
你能從[Assembly Binding log viewer](http://msdn.microsoft.com/en-us/library/e74a18c4.aspx)的綁定中獲得日誌嗎?確保首先將設置設置爲「記錄所有綁定」。 – rene
Assembly.LoadFrom()不能在像avcodec-52.dll這樣的DLL上工作,它不是.NET程序集。爲什麼你的代碼試圖像這樣加載它是完全不清楚的,如果你不發佈一個片段。 –
漢斯我沒有手動使用程序集,它在控制檯應用程序中運行良好。只有當我從ASP.NET應用程序引用它時,它纔會產生問題。 而我唯一使用的是引用Awesomium dll。 http://awesomium.com –