Failed to load file or assembly "PDFNet" or one of its dependencies. An attempt was made to download a program with the wrong format

I am trying to create a sample web application from an empty web form template in VS2012 and add a PDFNet file to it. If I run the project in .NET 3.5 without problems. If I run it in .NET> = 4, I will get this error:

Failed to load file or assembly "PDFNet64" or one of its dependencies. An attempt was made to download a program with the wrong format.

this is a stack trace:

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 

I have searched many times on the Internet and in google groups, and I have already tried these solutions (among others), IT and, for example, IT

I start a computer with Windows 8 x64, and I have the Visual C ++ 2010 x64 distribution installed on my computer. I also tried console applications provided by samples downloaded from pdftron.com and they work fine in all versions of .NET. I tried to create a console application myself, and this also works on all versions of .NET. Then I thought that this might be the error of the VS2012 development server, which works in x86 mode, so I set up the IIS website and started it from there, but still the same question. I am a little deprived of the opportunity, does anyone have any ideas? Thanx.

+4
source share
2 answers

The problem was resolved thanks to the support of @ pdftron.com guys. Here is the solution. In my particular case, I had the “Enable 32-bit Applications” application pool option in the IIS settings set to True, which somehow contradicted the x64 version of PDFNet.dll. Reset it to a false solution to the problem.

+6
source

enter image description here

Having made the Copy Local DLL into True, I resolved my case. The IIS application pool also requires 32 bit support.

+1
source

All Articles