Tôi có một dự án trong C# sử dụng thư viện C++ và một số dll. Khi tôi chạy nó nó hoạt động rất tốt.Mô-đun được mong đợi chứa một biểu hiện lắp ráp
Thư viện là Awesomium, chứa cả C++ thư viện và C# wrappers
Khi tôi tạo ra tài liệu tham khảo cho dự án này từ dự án ASP.NET MVC 4, tôi nhận được lỗi sau:
Ngoại lệ chi tiết: System.BadImageFormatException: Không thể tải tập tin hoặc tập tin 'tập tin: /// D: \ Projects \ Phát triển \ ProGamers \ GamingSite \ bin \ avcodec-52.dll' hoặc một trong những phụ thuộc của nó. Các mô-đun được dự kiến sẽ chứa một biểu hiện lắp ráp.
Những điều tôi đã cố gắng:
Đối phó dlls, nhưng nó vẫn không hoạt động (Các tập tin tồn tại).
Đăng ký nó trong GAC nhưng tôi gặp lỗi tương tự ở đó.
Hãy chắc chắn rằng sử dụng .NET Framework 4.0 (và không phải khách hàng hồ sơ)
2 files with the same dll/exe name causing conflict - Tôi không có nó.
Change the platform of the solution cho AnyCPU/nền tảng hỗn hợp.
Stack Trace:
[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
bạn có thể nhận nhật ký từ ràng buộc với [Trình xem nhật ký ràng buộc lắp ráp] không (http://msdn.microsoft.com/en-us/library/e74a18c4.aspx)? Đảm bảo đặt cài đặt trước để Ghi nhật ký tất cả các liên kết. – rene
Assembly.LoadFrom() không thể hoạt động trên một DLL như avcodec-52.dll, nó không phải là một assembly .NET. Tại sao mã của bạn cố gắng tải nó như thế này là hoàn toàn không rõ ràng nếu bạn không đăng một đoạn mã. –
Hans Tôi đã không sử dụng lắp ráp bằng tay, và nó làm việc tuyệt vời trong một ứng dụng giao diện điều khiển. Nó chỉ làm cho vấn đề chỉ khi tôi tham khảo nó từ ứng dụng ASP.NET của tôi. Và sử dụng duy nhất tôi đang làm là tham khảo các dlls Awesomium. http://awesomium.com –