SoftwareSavant
SoftwareSavant

Reputation: 9737

Entity Framework: Unable to load one or more of the requested types

I am getting a specific exception that I am confused about. I recently changed the target framework of my application from .net Framework 4.0 client profile to .net Framework 4.5. That has apparently caused my entity framework to go a little haywire. I get this exception when I run my application...

System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the
LoaderExceptions property for more information.
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.RuntimeModule.GetTypes()
   at System.Reflection.Assembly.GetTypes()
   at System.Data.EntityUtil.GetTypesSpecial(Assembly assembly)
   at System.Data.Metadata.Edm.ObjectItemAttributeAssemblyLoader.LoadTypesFromAssembly()
   at System.Data.Metadata.Edm.ObjectItemAssemblyLoader.Load()
   at System.Data.Metadata.Edm.ObjectItemAttributeAssemblyLoader.Load()
   at System.Data.Metadata.Edm.AssemblyCache.LoadAssembly(Assembly assembly, Boolean loadReferencedAssemblies, ObjectItemLoadingSessionData loadingData)

The thing is it used to work before I made this change... What did I manage to mess up? Do I need to regenerate these entities? How do I go about trouble shooting and fixing this problem? Thanks.

Upvotes: 1

Views: 2282

Answers (1)

jlew
jlew

Reputation: 10591

Two ways to debug this:

  1. Run your program in the debugger, turn on break-on-unhandled exceptions and then inspect the LoaderExceptions property of the exception like the message says. That should give you an idea of which type is not loading.

  2. Run fuslogvw.exe and inspect the failure that is logged there. If an assembly was not found or could not be loaded, it will tell you which one and possibly why.

Upvotes: 1

Related Questions