.net - 无法加载文件或程序集 'PDFNet' 或其依赖项之一。试图加载格式不正确的程序

标签 .net load .net-assembly

我正在尝试从 VS2012 中的空白 Web 表单模板构建示例 Web 应用程序,并向其中添加 PDFNet dll。如果我在 .NET 3.5 中运行项目没问题。如果我在 .NET >= 4 中运行它,我会收到此错误:

无法加载文件或程序集“PDFNet64”或其依赖项之一。试图加载格式不正确的程序。

这是堆栈跟踪:

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Program Files (x86)\IIS Express\iisexpress.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = COLLAB\mirko.lugano
LOG: DisplayName = PDFNet64
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: PDFNet64 | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///c:/users/mirko.lugano/documents/visual studio 2012/Projects/WebApplication3/WebApplication3/
LOG: Initial PrivatePath = c:\users\mirko.lugano\documents\visual studio 2012\Projects\WebApplication3\WebApplication3\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: c:\users\mirko.lugano\documents\visual studio 2012\Projects\WebApplication3\WebApplication3\web.config
LOG: Using host configuration file: C:\Users\mirko.lugano\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/ccfa215a/dc93c54d/PDFNet64.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/ccfa215a/dc93c54d/PDFNet64/PDFNet64.DLL.
LOG: Attempting download of new URL file:///c:/users/mirko.lugano/documents/visual studio 2012/Projects/WebApplication3/WebApplication3/bin/PDFNet64.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.


Stack Trace:


[BadImageFormatException: Could not load file or assembly 'PDFNet64' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   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.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +77
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +16
   System.Reflection.Assembly.Load(String assemblyString) +28
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38

[ConfigurationErrorsException: Could not load file or assembly 'PDFNet64' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +752
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +218
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170
   System.Web.Compilation.WebDirectoryBatchCompiler..ctor(VirtualDirectory vdir) +124
   System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal(VirtualDirectory vdir, Boolean ignoreErrors) +44
   System.Web.Compilation.BuildManager.BatchCompileWebDirectory(VirtualDirectory vdir, VirtualPath virtualDir, Boolean ignoreErrors) +187
   System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +74
   System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +299
   System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +103
   System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound) +165
   System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp) +43
   System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +31
   System.Web.UI.PageHandlerFactory.GetHandler(HttpContext context, String requestType, String virtualPath, String path) +37
   System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +346
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18033 

我已经在网络和谷歌组中搜索了很多,并且我已经尝试了这些解决方案(以及其他解决方案),THIS例如 THIS

我正在运行 Windows 8 x64 PC,并且我的机器上安装了 Visual c++ 2010 x64 可再发行组件。我还尝试了从 pdftron.com 下载的示例提供的控制台应用程序,这些应用程序在所有 .NET 版本中都可以正常工作。我曾尝试创建自己的控制台应用程序,它也适用于所有版本的 .NET。我当时以为可能是运行在x86模式下的VS2012开发服务器的问题,所以我设置了一个IIS网站并从那里运行它,但仍然是同样的问题。
我有点失落,有人有任何想法吗?谢谢。

最佳答案

感谢@ pdftron.com 的支持,问题已解决。 Here是解决方案。在我的特殊情况下,我将 IIS 设置中的“启用 32 位应用程序”应用程序池设置设置为 True,这在某种程度上与 PDFNet.dll 的 x64 版本冲突。将其重置为 false 解决了问题。

关于.net - 无法加载文件或程序集 'PDFNet' 或其依赖项之一。试图加载格式不正确的程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15498256/

相关文章:

.net - MVC 3-如何在 View 索引 View 而不是ID字段中显示查找值

c# - 比较时间而不考虑日期

testing - 无法从 jmeter 运行 webdriver 脚本

c# - 无法加载文件或程序集 log4net Version=1.2.10.0

.net - 在定义的目录中加载具有所需引用的程序集

c# - 无法将程序集安装到缓存?

c# - "ref"关键字和引用类型

.net - 将一个程序集安装到 GAC 上,用于 mono/.NET

c++ - 如何将内存块的指针转换为标准流

javascript - 当我更改 div 的内容时,div 仍保留旧内容