2012-10-30 8 views
9

VSでデバッグ中に、VSでデバッグを開始するとエラーが発生します。"ファイルまたはアセンブリまたはその依存関係の1つを読み込めませんでした。不正な形式のプログラムを読み込もうとしました。

エラーは以下の通りです:i「はp4dn.dll」を使用C#プロジェクトを作成すると

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 

全体で来て、このエラーはありません。

これは私の最初の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-attempt-was "であった。彼らは私の問題に対処できません。

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

+0

チェックした場合プロジェクトのフォルダ内のDLLのプロパティは読み取り専用かどうかです。読み取り専用の場合は、チェックマークを外します。 –

+0

私はそれをチェックして書き込み可能です。 –

答えて

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

1

==の各==>サイトのアプリケーションプール、

クリックし、このプールのためのあなたのウェブサイト -Enable 32ビット

9

行くため-create新しいIISプールに>アドバンス設定

 Change value of ==> "Enable 32-Bit Applications" from False to True 
+0

私はこの問題にぶつかったとき、これはいつも正しい答えでした。 –

+0

hah、私はちょうどこの問題をもう一度解決しました。もう一度それを解決して、同じ投稿に戻って、もう一度upvoteしてみました。そして、私の古いコメント、ああ思い出を見ました。 –

+0

:)はいいいえ、それはたくさん起こります。私たちは同じ問題に再び来て、私たちはそれを探し回ってそれに来ます。私は覚えています。 !! :) –

14

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

プロジェクト「ウェブサイトおよびプロジェクトのためのIISエクスプレスの64ビットバージョンを使用してください」のボタンをクリックして

+1

なぜこれが見つけにくいのですか?確かに64ビットVSスタジオを選択する場合は、これを把握するのに十分なスマートでなければなりません! – SlimCheney

+0

それは賢明ではありません、それは確かに迷惑です! –

+0

それは私のために働いた。 –

関連する問題