Now I promise that I was looking for this. Stack overflow has about 4 or 5 solutions to this problem. However, none of them seem to be working. I am using EntityFramework 5 (4.4) with an MVC 3 project. This worked well in the past, but it has been a while since I opened the project (about 20 days or so). I just uninstalled and reinstalled Sql Server 2008 R2 Express. I have rebooted since.
In all my cshtml files, I see an error on my @model line. When I hover over it, I see the following:
ASP.NET runtime error: Could not load file or assembly "EntityFramework, Version = 4.4.0.0, Culture = neutral, PublicTokenKey = b77a5c561934e089" or one of its dependencies. Access is denied.
I uninstalled and reinstalled the EntityFramework package through the package manager console. I did it through nuget. I closed and reopened the visual studio. I deleted the link and added it manually while browsing the DLL.
My web.config entry for this looks like this:
[open tag] section name = "entityFramework" type = "System.Data.Entity, EntityFramework, Version = 4.4.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089" requirePermission = "false" [closing tag]
Anyone have any thoughts?
EDIT 1 TOTAL ERROR ERROR
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
EDIT 2
In the above debugging information, I manually added the entire DLL used by the application to the folder C: \ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ Temporary ASP.NET \ root \ 014aecc8 \ d1c2eaf7, as it was finally mentioned that the error constantly changing.
I do not see the ASPNET user assigning permissions to the C: \ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ Temporary ASP.NET Files \ directory. I added: IUSR, NETWORK, NETWORK SERVICE, IIS_USRS (\ IIS_ISURS) with full control. I am still getting the error message.
Since I was still getting Access Denied for errors, I gave users full control over the folder on my machine. The application is loading. So ... this is a permission error. The question is, which account needs permissions?