我们正在尝试使用WebSupergoo的ABCpdf .NET v10。如果我们使用他们的安装程序,它会很好用。但是v8已经安装在服务器上,其他项目使用它,所以我们不想在此时运行安装程序。 (希望在不久的将来,我们可以在不同的机器上测试安装和/或升级这些项目,但是这个项目不能等待。)
"手动安装"来自WebSupergoo(http://www.websupergoo.com/helppdfnet/default.htm?page=source%2F3-concepts%2F6-installation.htm)的说明指示将3个主要DLL(ABCpdf.dll,ABCpdf10-32.dll和ABCpdf10-64.dll)放入bin文件夹并添加对ABCpdf.dll的引用。
我们并不真正想要它们在bin文件夹中,因为Source Control设置为不从该文件夹添加任何内容。然而,为了让它工作(现在),他们被放置在该文件夹中。然后,当我尝试运行项目时,出现以下错误(文件夹名称已更改以确保安全性):
System.BadImageFormatException was unhandled by user code
HResult=-2146234344
Message=Could not load file or assembly 'file:///D:\\Projects\Solution\WebProject\bin\ABCpdf10-32.dll' or one of its dependencies. The module was expected to contain an assembly manifest.
Source=mscorlib
FileName=file:///D:\Projects\Solution\WebProject\bin\ABCpdf10-32.dll
FusionLog==== Pre-bind state information ===
LOG: Where-ref bind. Location = D:\Projects\Solution\WebProject\bin\ABCpdf10-32.dll
LOG: Appbase = file:///D:/Projects/Solution/WebProject/
LOG: Initial PrivatePath = D:\Projects\Solution\WebProject\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: D:\\Projects\Solution\WebProject\web.config
LOG: Using host configuration file: D:\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Attempting download of new URL file:///D:/Projects/Solution/WebProject/bin/ABCpdf10-32.dll.
ERR: Failed to complete setup of assembly (hr = 0x80131018). Probing terminated.
StackTrace:
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
at System.Reflection.Assembly.LoadFrom(String assemblyFile)
at WebActivator.PreApplicationStartCode.Start() in D:\Code\Bitbucket\WebActivator\WebActivator\PreApplicationStartCode.cs:line 11
InnerException:
我们首选的方法是将它们放在" lib"文件夹(目前处于解决方案级别)。所以,我将3个DLL放在该文件夹中并添加了引用。项目编译并运行,但是当我们尝试创建PDF时,我们会收到以下错误:
Unable to load DLL 'ABCpdf10-32.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
WebSupergoo支持说:" ABCpdf10-32.dll不是程序集,所以它当然不包含程序集清单"。
我尝试将ABCpdf10-32.dll从bin文件夹中取出,我在ABCpdf10-64.dll中遇到同样的错误。
我尝试设置"复制本地"引用False。没有变化。
复制本地:https://msdn.microsoft.com/en-us/library/t1zz5y8c(v=vs.90).aspx
我尝试使用"探测"技术。我在web.config&中尝试过它。项目的app.config文件(似乎不是解决方案的一个)。我也尝试将lib文件夹移动到项目本身。没有变化。
探索:https://msdn.microsoft.com/en-us/library/823z9h8w(v=vs.110).aspx
我不确定此时还有什么可以尝试的。任何帮助将不胜感激!
答案 0 :(得分:0)
System.BadImageFormatException是一个常见的异常,用于在64位环境中使用32位DLL时发生,或者反之亦然。
Web应用程序:它们用于加载文件夹上的所有dll,无论是否使用(WebActivator.PreApplicationStartCode.Start())。 检查IIS池,它是64位?然后删除文件夹或子文件夹中的所有32 dll。 你强迫它到32岁?然后删除文件夹或子文件夹中的所有64 dll。