2013-03-19 47 views
4

我試圖從VS2012中的空白web表單模板構建一個示例web應用程序,並將PDFNet dll添加到它。如果我在.NET 3.5中運行該項目沒有問題。如果我在.NET> = 4中運行它,我會看到以下錯誤:無法加載文件或程序集「PDFNet」或其某個依賴項。試圖加載格式不正確的程序

無法加載文件或程序集「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。然後我認爲這可能是VS2012開發服務器在x86模式下運行的錯誤,所以我建立了一個IIS網站並從那裏運行它,但仍然是同樣的問題。 我有點失落,有沒有人有任何想法?感謝名單。

+0

在您的IIS站點嘗試將AppPool設置爲在32位模式下運行 – 2013-03-19 12:13:50

+0

您的意思是「高級設置」下的「啓用32位應用程序」設置爲true?已經嘗試過,沒有運氣。我使用的PDFNet DLL無論如何都是x64 dll。 – 2013-03-19 12:28:56

回答

6

由於@ @ pdftron.com的支持,問題得以解決。 Here是解決方案。在我的特殊情況下,我將IIS設置中的「啓用32位應用程序」應用程序池設置設置爲True,這與PDF 64.dll的x64版本存在衝突。將它重置爲false可以解決問題。

1

enter image description here

通過將DLL的 「複製本地」 設置爲True解決了我的情況。 IIS應用程序池還需要32位支持關閉。

+0

如果一切都失敗,請嘗試手動將文件複製到「Bin」文件夾。有時它有助於節省調試時間。 – SurenSaluka 2017-06-09 13:43:08

相關問題