20

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 -試みた-だった」。彼らは私の問題に対処できません。

どうすればこの問題を解決できますか?

4

5 に答える 5

50

IIS Express の 64 ビット バージョンを実行するためのメニュー オプションが追加されました。Visual Studio のメニューから、[ツール] -> [オプション...] -> [プロジェクトとソリューション] -> [Web プロジェクト] を選択します。

「Web サイトおよびプロジェクトに 64 ビット バージョンの IIS Express を使用する」のボタンをクリックします。

于 2016-05-15T20:29:44.830 に答える
5

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 チームは、これをプロジェクト プロパティのオプションにする必要があります。

于 2012-12-31T17:23:32.187 に答える