こんにちは、助けてくれてありがとう、この質問または同様の質問が、MVC 3 アプリケーションに関して頻繁に投稿されていることを知っています。ただし、.net 4.0 ターゲット フレームワークを使用して Visual Web Developer Express 2010 内からアプリケーションを起動しようとすると、常にこのエラー メッセージが表示されます。
正確なエラー メッセージは次のとおりです。
セキュリティの透過的なメソッド 'System.Runtime.Diagnostics.DiagnosticTrace..ctor(System.String, System.Guid)' によって、セキュリティ クリティカルなメソッド 'System.Runtime.Diagnostics.EtwDiagnosticTrace..ctor(System.String, System.Guid) にアクセスしようとしています)' 失敗しました`.
アセンブリ 'System.ServiceModel.Internals, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' は、AllowPartiallyTrustedCallersAttribute でマークされ、レベル 2 のセキュリティ透過性モデルを使用します。レベル 2 の透過性により、AllowPartiallyTrustedCallers アセンブリ内のすべてのメソッドが既定で透過的なセキュリティになります。これが、この例外の原因である可能性があります。
スタックトレース:
[MethodAccessException: Attempt by security transparent method 'System.Runtime.Diagnostics.DiagnosticTrace..ctor(System.String, System.Guid)' to access security critical method 'System.Runtime.Diagnostics.EtwDiagnosticTrace..ctor(System.String, System.Guid)' failed.
Assembly 'System.ServiceModel.Internals, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is marked with the AllowPartiallyTrustedCallersAttribute, and uses the level 2 security transparency model. Level 2 transparency causes all methods in AllowPartiallyTrustedCallers assemblies to become security transparent by default, which may be the cause of this exception.]
System.Runtime.Diagnostics.DiagnosticTrace..ctor(String traceSourceName, Guid etwProviderId) +24
System.ServiceModel.Activation.FxTrace.InitializeTracing() +90
System.ServiceModel.Activation.FxTrace.get_Trace() +84
System.ServiceModel.ServiceHostingEnvironment.EnsureInitialized() +59
System.ServiceModel.ServiceHostingEnvironment.OnEnsureInitialized(Object state) +4
System.ServiceModel.AspNetPartialTrustHelpers.PartialTrustInvoke(ContextCallback callback, Object state) +52
System.ServiceModel.ServiceHostingEnvironment.SafeEnsureInitialized() +65
System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e) +58
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +143
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
私はここで完全に途方に暮れています。基本的なアプリケーションをゼロから作成して起動しようとすると、何も追加していなくても、このエラー画面が表示されます。から target framework="4.0" 属性を削除しようとしました
<compilation debug="true" targetFramework="4.0" />
タグを付けて実行しても結果はありません。その属性を削除して追加しようとしました
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v2.0.50727"/>
<supportedRuntime version="v4.0.30319"/>
</startup>
このスレッドで提案されているように: BadImageFormatException - 実行可能ファイルの実行に使用される .NET バージョンを指定することは可能ですか? 問題があるかもしれないと聞いたので、.Net 4.0 フレームワークのインストールを修復してみました。試用版の有効期限が切れたために Microsoft Visual Studio 2010 から移行したプロジェクトで作業するために、昨夜 Visual Web Developer をインストールしました。