![](/img/trans.png)
[英]How I can fix 'Could not load file or assembly 'Spss' or one of its dependencies. An attempt was made to load a program with an incorrect format.'?
[英]“Could not load file or assembly or one of its dependencies. An attempt was made to load a program with an incorrect format.”
在 VS 中調試時,在 VS 中啟動調試時會引發錯誤。
錯誤如下:
Could not load file or assembly 'p4dn, Version=1.0.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.BadImageFormatException: Could not load file or assembly 'p4dn, Version=1.0.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[BadImageFormatException: Could not load file or assembly 'p4dn, Version=1.0.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +43
System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +127
System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +142
System.Reflection.Assembly.Load(String assemblyString) +28
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +46
[ConfigurationErrorsException: Could not load file or assembly 'p4dn, Version=1.0.1.0, Culture=neutral, PublicKeyToken=null' 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) +613
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +203
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +105
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178
System.Web.Compilation.BuildProvidersCompiler..ctor(VirtualPath configPath, Boolean supportLocalization, String outputAssemblyName) +54
System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean isPrecompiledApp) +232
System.Web.Compilation.BuildManager.CompileGlobalAsax() +51
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +337
[HttpException (0x80004005): Could not load file or assembly 'p4dn, Version=1.0.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Web.Compilation.BuildManager.ReportTopLevelCompilationException() +58
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +512
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters) +729
[HttpException (0x80004005): Could not load file or assembly 'p4dn, Version=1.0.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +8921851
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +85
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +259
當我創建一個使用“p4dn.dll”的 C# 項目時,不會出現此錯誤。
這是我的第一個 ASP 項目,我還閱讀了類似的問題,例如“http://stackoverflow.com/questions/41449/i-get-a-an-attempt-was-made-to-load-a-program-with -an-incorrect-format-error-o”和“http://stackoverflow.com/questions/1648213/could-not-load-file-or-assembly-xxx-or-one-of-its-dependencies-an -嘗試-是”。 他們無法解決我的問題。
我怎么解決這個問題?
現在有一個菜單選項可以運行 64 位版本的 IIS Express。 從 Visual Studio 菜單中選擇工具 -> 選項... -> 項目和解決方案 -> Web 項目
單擊“為網站和項目使用 64 位版本的 IIS Express”按鈕
轉到各自 ==> 站點應用程序池,
單擊 ==> 高級設置
Change value of ==> "Enable 32-Bit Applications" from False to True
我在嘗試使用 IIS Express 8.0 運行(調試)64 位 MVC 站點時遇到了同樣的錯誤消息。 我確認我所有的項目都針對 x64 平台。
出現此問題是因為 Visual Studio 運行 32 位版本的 IIS Express。 我讓它工作的唯一方法是通過手動執行以下命令來運行 64 位 IIS Express。
"C:\Program Files\IIS Express\iisexpress.exe" /config:"U:\IISExpress\config\applicationhost.config" /site:"Imaging.Web" /apppool:"Clr4IntegratedAppPool"
然后在您的 Visual Studio Web 項目中,轉到“屬性”,選擇“使用自定義 Web 服務器”,然后輸入您站點的 url。
要進行調試,請轉到調試 > 附加到進程...,然后選擇正在運行的 IIS Express 實例。
Visual Studio 團隊確實應該將其作為項目屬性中的一個選項。
-為您的網站創建一個新的 IIS 池 -為此池啟用 32 位
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.