Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework 6.1.3 Could not load

So I have seen a bunch of answers to this question. None seem to resolve my issue. I am running the project as a self hosted webservice using servicestack.

  • Yes I have uninstalled and reinstalled entity framework, cleaned solution, restarted visual studio, rebuilt
  • Yes I have checked all binding redirects.
  • Yes I have checked that EntityFramework Dll is in the folder being searched for the dll.
  • Yes I have permissions to this folder (out of desperation I put the project on my own desktop to eliminate security issues).
  • Yes the nuget package, the project and all configs have .net 4.5.1 as their target platforms.

Despite all of this, I still get the error:

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

=== Pre-bind state information ===
LOG: DisplayName = EntityFramework
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: EntityFramework | Domain ID: 1
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:/Users/MyUserName/Desktop/TempFolder/Web.MyProject.Service/bin/x86/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\MyUserName\Desktop\TempFolder\Web.MyProject.Service\bin\x86\Debug\Web.MyProject.Service.vshost.exe.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:/Users/MyUserName/Desktop/TempFolder/Web.MyProject.Service/bin/x86/Debug/EntityFramework.DLL.
ERR: A fatal error occurred when retrieving next codebase for download (hr = 0x80070005).

Can anyone point me at some tools to track down the cause of the problem (unless you know what the problem is ;-D).

like image 736
Bitfiddler Avatar asked Mar 11 '23 23:03

Bitfiddler


1 Answers

Turns out the "Access is Denied" was not lying. The context I was working with was a wrapper around (inherited from) an actual EntityFramework context which implemented some impersonation in the constructor. The impersonated user did not have access to the bin directory which is the reason for the error.

like image 83
Bitfiddler Avatar answered Apr 27 '23 13:04

Bitfiddler