Entity Framework 5 - Could not load file or assembly EntityFramework, Version=5.0.0.0
Asked Answered
T

7

13

I am trying to use Entity Framework 5 for my project but I seem to be having some issue getting the assembly installed to comply. And since I installed this initially using nuget, I am not certain what I need to do to cause this to work as I expect . Any help on what I need to do to fix this problem please?

*System.IO.FileNotFoundException : Could not load file or assembly EntityFramework, Version=5.0.0.0, Culture=Neutral, PublicKeyToken=b77a5c561934e089' or one of it's dependencies The System cannot find the file specified.WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registy value . . . *

by using fusion log, i got this

*** Assembly Binder Log Entry  (7/17/2012 @ 9:29:09 PM) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 11.0\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\vstest.executionengine.x86.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = WORKALOT\Tokorie
LOG: DisplayName = Budget.Data, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = file:///C:/Development/Summer2012BudgetApp/Budget.Service.Test/bin/Release
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = vstest.executionengine.x86.exe
Calling assembly : Budget.Lib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 11.0\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\vstest.executionengine.x86.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:/Development/Summer2012BudgetApp/Budget.Service.Test/bin/Release/Budget.Data.DLL.
LOG: Attempting download of new URL file:///C:/Development/Summer2012BudgetApp/Budget.Service.Test/bin/Release/Budget.Data/Budget.Data.DLL.
LOG: Attempting download of new URL file:///C:/Development/Summer2012BudgetApp/Budget.Service.Test/bin/Release/Budget.Data.EXE.
LOG: Attempting download of new URL file:///C:/Development/Summer2012BudgetApp/Budget.Service.Test/bin/Release/Budget.Data/Budget.Data.EXE.
LOG: All probing URLs attempted and failed.
Topee answered 13/7, 2012 at 13:20 Comment(7)
You are using .Net 4.5 right?Crinkly
yes, I am using .NET 4.5, VS 2012 RC, and EF 5Topee
How is your project structure looks like? Have you installed EF everywhere where you use it, e.g Web project and DAL project etc. ?Valene
what do you mean installed everywhere i use it? I only have one data access layer, and so I have it installed there.Topee
check all your projects, if theres a reference to entity framework, and check that its 5.0, not the old 4.*. I had the same problem, and that solved it for me. also check your web.config, if there is more than one reference to entity framework there. (even try to comment out the 5.0 reference in web.config, and see if that helps).Rilda
The only project that has EF5 reference is confirmed to contain EF5Topee
Is it a compile error or runtime?Braided
S
5

Run the fusion log tool as suggested by the error message to get more information about where the runtime is looking for the dll's so you get a better idea of why it is failing.

There is a good article about Fusion-loggning by Scott Hanselman, how you enable it etc, then just run fuslogw as admin from command prompt.

Update

The fusion log shows us where the runtime is looking for your DLLs, in this case Budget.Data, which it looks for in:

bin/Release/Budget.Data.DLL 
bin/Release/Budget.Data/Budget.Data.DLL
bin/Release/Budget.Data.EXE
bin/Release/Budget.Data/Budget.Data.EXE

Can you verify that the DLL is in fact in one of these directories ? If it is check the target framework on your DLL (check the project properties) ? Is the target framework compatible with EF 5.0 ? What is the target framework of your other assemblies (if any)

Stale answered 17/7, 2012 at 7:29 Comment(2)
So far, Fusion log has yet to help me. What exactly should I be looking out for? please see update above.Topee
Not sure what happened there, added a better link to article by Scott H.Stale
M
4

Are you sure the path is correct? Try to remove the "Entity Framework" reference and re-adding it manually.

Right click to add a reference, then browse here and add the dll:

C:\PATH\TO\SOLUTION\packages\EntityFramework.5.0.0-rc\lib\net45\EntityFramework.dll

Also make sure the path is set in the csproj file of the project (right click project, unload, right click again and then "Edit projectname.csproj"), you should have something like this:

<Reference Include="EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..\packages\EntityFramework.5.0.0-rc\lib\net45\EntityFramework.dll</HintPath>
</Reference>

Other things to check would be the packages.config file to make sure it's referenced there, and also make sure that the Entity Framework reference's "Copy Local" property is set to true. You might also have to reference the assembly in your web.config file if you're using it in an ASP.NET projcet or something similar.

Mellophone answered 18/7, 2012 at 18:30 Comment(0)
B
1
  1. Check the flag "copy local"
  2. Check the assembly dll exists in out put folder
  3. Check reference in solution. Try readd reference.
  4. Check the version and public key of assembly and in solution file (You can open the visual studio solution file and edit it in text editor. Try remove public key from solution file and set correct version if its difers)
  5. Also this problem can hapen when some assembly you add to solution references to assembly that you did't have. If that try to get correct assembly or try rebuild assembly with libraries you have.

Good luck!

Braided answered 17/7, 2012 at 9:29 Comment(3)
Copy Local flag is already set to true. Runtime Version information says v.4.0.30319. and the version information is 5.0.0.0. Specific Version is set to False, and Resolve is set to true on the EntityFramework reference in my project.Topee
I am using CodeFirst so I just have EF5 in the one project which I consider my data access layerTopee
Is the assembly of ef5 exists in output folder?Braided
P
1

I actually had this problem myself the other day, when working with version control (git) and the Nuget package for ef5-rc. What solved the issue for me was to remove (delete in Windows explorer) the assembly from the solutions' "packages" folder. When i restarted Visual Studio Nuget gave me the opportunity to restore packages. Hope this helps!

Pleasance answered 19/7, 2012 at 10:56 Comment(0)
H
0

What blocks are you using from EntLib5? Since you are calling it from the DAL, I will assume you are calling Microsoft.Practice.EnterpriseLibrary.Data.

If so, I just want to point out that I always needed all of the following DLLs to get the EntLib5 DAAB to work for me.

Microsoft.Practices.EnterpriseLibrary.Common
Microsoft.Practices.EnterpriseLibrary.Data
Microsoft.Practices.Unity
Microsoft.Practices.Unity.Interception

Missing any one of those references will cause my project to error out at runtime, even if compiles fine.

I would also try running the EntLib5 installer from http://www.microsoft.com/en-us/download/details.aspx?id=15104, since it sticks the DLLs into the GAC.

Hesta answered 19/7, 2012 at 0:16 Comment(0)
S
0

I ended up solving this for a project I am working on. I ended up deleting everything in the .bin folder for the project that was throwing the error. I assume that these files only get re-written as specific times or when a .dll changes etc. and was not handled by the migration over. Deleting those files, cleaning the solution and rebuilding seemed to solve the problem for me.

Slickenside answered 15/10, 2012 at 5:13 Comment(0)
G
0

I'm getting this problem too. So I did a bit of a look around and found the following.

In the "Common Problems" section of http://msdn.microsoft.com/en-us/data/jj618307.aspx it says...

"This typically means that you are running a .NET 4 application without the Redirect.config file. You need to copy the Redirect.config to the same location as migrate.exe and rename it to migrate.exe.config."

Unfortunately, I don't know where Redirect.config is located. The cannot find it anywhere in the NuGet package's directory contents.

Goof answered 6/12, 2013 at 3:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.