5

今、私はこれをググったことを約束します。スタック オーバーフローには、この問題に対する 4 つまたは 5 つの解決策があります。それでも、どれも機能していないようです。MVC 3 プロジェクトで EntityFramework 5 (4.4) を使用しています。これは過去にうまくいきましたが、プロジェクトを開いてからしばらく経ちました (約 20 日ほど)。Sql Server 2008 R2 Express をアンインストールして再インストールしました。それ以来、私は再起動しました。

すべての cshtml ファイルで、@model 行にエラーの下線が表示されます。マウスオーバーすると、次のように表示されます。

ASP.NET ランタイム エラー: ファイルまたはアセンブリ 'EntityFramework、Version=4.4.0.0、Culture=neutral、PublicTokenKey=b77a5c561934e089' またはその依存関係の 1 つを読み込めませんでした。アクセスが拒否されました。

パッケージ マネージャー コンソールから EntityFramework パッケージをアンインストールして再インストールしました。私もナゲット経由でそれをやった。ビジュアルスタジオを閉じて再開しました。参照を削除し、dll を参照して手動で追加しました。

これに対する私の web.config エントリは次のようになります。

[開始タグ]セクション名="entityFramework" type="System.Data.Entity、EntityFramework、Version=4.4.0.0、Culture=neutral、PublicKeyToken=b77a5c561934e089" requirePermission="false" [終了タグ]

誰でも何か考えがありますか?

EDIT 1 の完全なエラーの詳細

Server Error in '/' Application.

Could not load file or assembly 'EntityFramework' or one of its dependencies. Access is denied.

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.IO.FileLoadException: Could not load file or assembly 'EntityFramework' or one of its dependencies. Access is denied.

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.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'EntityFramework' could not be loaded.


=== Pre-bind state information ===
LOG: User = Unknown
LOG: DisplayName = EntityFramework
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: EntityFramework | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/MercurialProjects/ProxySetup/ProxySetup/
LOG: Initial PrivatePath = C:\MercurialProjects\ProxySetup\ProxySetup\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\MercurialProjects\ProxySetup\ProxySetup\web.config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/014aecc8/d1c2eaf7/EntityFramework.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/014aecc8/d1c2eaf7/EntityFramework/EntityFramework.DLL.
LOG: Attempting download of new URL file:///C:/MercurialProjects/ProxySetup/ProxySetup/bin/EntityFramework.DLL.
LOG: Using application configuration file: C:\MercurialProjects\ProxySetup\ProxySetup\web.config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
ERR: Failed to complete setup of assembly (hr = 0x80070005). Probing terminated.

Stack Trace: 


[FileLoadException: Could not load file or assembly 'EntityFramework' or one of its dependencies. Access is denied.]

[FileLoadException: Could not load file or assembly 'EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. Access is denied.]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +39
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +132
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +144
   System.Reflection.Assembly.Load(String assemblyString) +28
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +46

[ConfigurationErrorsException: Could not load file or assembly 'EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. Access is denied.]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +618
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +209
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178
   System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +94
   System.Web.Compilation.BuildManager.CallPreStartInitMethods() +332
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +677

[HttpException (0x80004005): Could not load file or assembly 'EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. Access is denied.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9090988
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
   System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +258

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272

編集2

上記のデバッグ情報に従って、アプリケーションが使用するすべての dll を C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\014aecc8\d1c2eaf7 フォルダーに手動で追加しました。エラーが変化し続けたので。

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\ ディレクトリにアクセス許可を割り当てる ASPNET ユーザーが見つかりません。IUSR、NETWORK、NETWORK SERVICE、IIS_USRS (\IIS_ISURS) をフル コントロールで追加しました。私はまだエラーが発生しています。

エラーで Access Denied がまだ発生していたので、自分のマシンのフォルダーをユーザーに完全に制御できるようにしました。アプリケーションがロードされます。つまり...これは許可エラーです。問題は、どのアカウントにアクセス許可が必要かということです。

4

2 に答える 2

2

これは奇妙に思えるかもしれませんが、この問題やこのような問題に遭遇した後、非常に標準外である 2 つの考えられる原因を特定しました。

1) クロムを使用している場合は、ソリューションをビルドしようとするときにクロムが閉じていることを確認してください (このエラーの結果としてソリューションをビルドできないと思いますか?)。おかしなことに聞こえるかもしれませんが、開発中に chrome を使用しているときに、何らかの理由で特定のファイルにアクセスできなくなることがあります。理由はまだわかりませんが、問題を解決できなかった場合は試してみる価値があります。

2) nuget パッケージ マネージャーで、エンティティ フレームワークをまだ再インストールしていない場合は、アンインストールしてから再インストールします。アプリをあるマシンから別のマシンに移動したり、バージョン管理から更新したりすると、nuget パッケージが何らかの形で台無しになることがわかりました。再インストールすることは、それを軌道に乗せるための唯一のことのようです。

3) パーミッション固有の問題については、それが問題であるとは確信していませんが、アプリ フォルダー全体とサブフォルダー/ファイルには、ユーザー "Everyone" に完全な読み取り/実行パーミッションを設定する必要があります (ただし、書き込みパーミッションではありません)。アクセス許可に関して必要なのはこれだけです (少なくとも、セットアップ中に必要と思われるのはそれだけです)。

幸運を。

于 2013-05-09T05:19:42.627 に答える