"不正な形式のプログラムを読み込もうとしました"というエラーが発生するという珍しい問題がありますか?私は同じIISサーバー上に2つの同一のWebサイトを持ち、私の構築構成はそのうちの1つでは動作しますが、他の構成では機能しません。IIS 7.5 Fixingフォーマットに問題があるプログラムを読み込もうとしましたか?
私のC#MVC 2 Webアプリケーションは、同じIIS 7.5 Webサーバー(x64)に存在する2つのWebサイトに展開できます。 1つはライブサイト(リリース構成を使用して展開)、2番目はベータサイト(このプロジェクト用に作成された新しいベータ設定を使用して展開)です。両方のプロジェクトのコードベースは同じです。彼らは異なるビルド構成を持っていますが、構成内の設定は同じです。
デフォルトのウェブサイト/ my_appにリリース設定を展開すると、完全に動作します。
Beta/my_appにベータ版をデプロイしますが、サイト(任意のページ)を読み込んだときに不正な形式の例外が発生します。
全く同じ設定が1つのWebサイトでは動作するが、別のWebサイトでは動作しない(同じWebサーバー上で)ことはできません。私のサーバー+ devマシンは64ビットで、両方のWebサイトに同じアプリケーションプール設定(.NET 4、統合)があります。
どのようにしてこの問題を発見/修正できますか?各サイトの設定を変更する必要はありません。そして、できればリリースの設定を変更する必要はありません。動作しているので、変更するリスクはありません。
2つのウェブサイトは次のとおりです。
Default Website/my_app
Beta/my_app
リリースのコンフィギュレーション・マネージャは、これらの設定があります。
ベータ版のためのコンフィギュレーション・マネージャは、まったく同じ設定があります。
例外は次のとおりです。
Could not load file or assembly 'MyApp.Domain.Model' or one of its dependencies.
An attempt was made to load a program with an incorrect format.
Stack Trace:
[BadImageFormatException: Could not load file or assembly 'MyApp.Domain.Model' 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, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +567
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +192
System.Reflection.Assembly.Load(String assemblyString) +35
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +123
[ConfigurationErrorsException: Could not load file or assembly 'MyApp.Domain.Model' 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) +11479520
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +484
System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +79
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +334
System.Web.Compilation.BuildManager.CallPreStartInitMethods() +280
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1087
[HttpException (0x80004005): Could not load file or assembly 'MyApp.Domain.Model' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11612256
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4842149
私はSO「の試みが間違ったフォーマットのプログラムをロードするために作られた」が、私はこれが重複するとは考えていないについての質問に複数の質問があることを見てきました。これは、設定が1つのサイトでうまく動作するが、同じ設定と同じウェブサーバーを両方使用する別のサイトではうまく動作しないというユニークな状況です。
あなたはカッシーニでこれを実行すると何が起こりますか? – Illuminati