gpt4 book ai didi

c# - 另一个无法加载文件或程序集'EntityFramework

转载 作者:太空狗 更新时间:2023-10-29 23:40:02 24 4
gpt4 key购买 nike

现在,我保证我已经用谷歌搜索过了。 Stack overflow 对此问题有大约 4 或 5 个解决方案。尽管如此,他们似乎都没有工作。我将 EntityFramework 5 (4.4) 与 MVC 3 项目一起使用。这在过去工作得很好,但自从我打开该项目以来已经有一段时间了(大约 20 天左右)。我刚刚卸载并重新安装了 Sql Server 2008 R2 Express。从那时起我就重新启动了。

在我所有的 cshtml 文件中,我在 @model 行上看到错误下划线。当我将鼠标悬停在上面时,我会看到以下内容:

ASP.NET 运行时错误:无法加载文件或程序集“EntityFramework,Version=4.4.0.0,Culture=neutral,PublicTokenKey=b77a5c561934e089”或其依赖项之一。访问被拒绝。

我已经通过包管理器控制台卸载并重新安装了 EntityFramework 包。我也通过 nuget 完成了它。我已经关闭并重新打开了 Visual Studio 。我已删除引用并通过浏览 dll 手动添加它。

我的 web.config 条目如下所示:

[open tag]section name="entityFramework" type="System.Data.Entity, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" [close tag]

大家有什么想法吗?

编辑 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) 具有完全控制权。我仍然收到错误消息。

由于我仍然因错误而被拒绝访问,我让用户完全控制我机器上的文件夹。应用程序加载。所以...这是一个权限错误。问题是,哪个帐户需要权限?

最佳答案

这可能看起来很奇怪,但在遇到这个问题以及类似的问题之后,我确定了两个非常不正常的可能原因。

1) 如果您使用的是 chrome,请确保在尝试构建解决方案时 chrome 已关闭(我假设您由于此错误而无法构建解决方案?)。我知道这听起来很疯狂,但我发现有时,无论出于何种原因,当我在开发过程中使用 chrome 时,某些文件变得无法访问。我仍然不知道为什么,但如果您无法解决问题,那值得一试。

2) 在您的 nuget 包管理器中,如果您尚未重新安装 Entity Framework ,请将其卸载并重新安装。我发现当我将应用程序从一台机器移动到另一台机器时,或者我从版本控制更新它时,nuget 包会以某种方式搞砸。重新安装似乎是让它走上正轨的唯一方法。

3) 关于您的权限特定问题,我不认为这是问题所在,但是,您的整个应用程序文件夹和子文件夹/文件应该为用户“Everyone”设置完全读取/执行权限(但不是写入权限) ).这应该是您在权限方面所需要的全部(至少这就是我在设置过程中似乎所需要的)。

祝你好运。

关于c# - 另一个无法加载文件或程序集'EntityFramework,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14388148/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com