Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. with EntityDataSource

I have a problem that only shows if EntityDataSource present on ASP.NET (*.aspx) pages. The interesting thing it's just occurs when I'm refreshing the page (F5) or viewing it again and it's driving me crazy it seems to be a bug with Entity Framework, because I tried it with another project, and I just get the same error.

Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. 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.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

Stack trace:

[ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.]
   System.Reflection.RuntimeModule.GetTypes(RuntimeModule module) +0
   System.Reflection.RuntimeModule.GetTypes() +4
   System.Reflection.Assembly.GetTypes() +78
   System.Data.Metadata.Edm.ObjectItemConventionAssemblyLoader.LoadTypesFromAssembly() +32
   System.Data.Metadata.Edm.ObjectItemAssemblyLoader.Load() +25
   System.Data.Metadata.Edm.AssemblyCache.LoadAssembly(Assembly assembly, Boolean loadReferencedAssemblies, ObjectItemLoadingSessionData loadingData) +160
   System.Data.Metadata.Edm.AssemblyCache.LoadAssembly(Assembly assembly, Boolean loadReferencedAssemblies, KnownAssembliesSet knownAssemblies, EdmItemCollection edmItemCollection, Action`1 logLoadMessage, Object& loaderCookie, Dictionary`2& typesInLoading, List`1& errors) +166
   System.Data.Metadata.Edm.ObjectItemCollection.LoadAssemblyFromCache(ObjectItemCollection objectItemCollection, Assembly assembly, Boolean loadReferencedAssemblies, EdmItemCollection edmItemCollection, Action`1 logLoadMessage) +316
   System.Data.Metadata.Edm.ObjectItemCollection.ExplicitLoadFromAssembly(Assembly assembly, EdmItemCollection edmItemCollection, Action`1 logLoadMessage) +53
   System.Data.Metadata.Edm.MetadataWorkspace.ExplicitLoadFromAssembly(Assembly assembly, ObjectItemCollection collection, Action`1 logLoadMessage) +93
   System.Data.Metadata.Edm.MetadataWorkspace.LoadFromAssembly(Assembly assembly, Action`1 logLoadMessage) +130
   System.Web.UI.WebControls.EntityDataSourceView.ConstructContext() +585
   System.Web.UI.WebControls.EntityDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +76
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +21
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +143
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +74
   System.Web.UI.WebControls.GridView.DataBind() +4
   System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +66
   System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +75
   System.Web.UI.Control.EnsureChildControls() +102
   System.Web.UI.Control.PreRenderRecursiveInternal() +42
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2496

How can I fix this problem?

like image 897
Milady Avatar asked Sep 28 '10 14:09

Milady


4 Answers

This is a bug in .NET 4.0 and should be fixed in .NET 4.5. A possible solution is to set "Copy local" to true on your references and remove unneeded references.

More information is in Unable to load one or more of the requested types. Connected with EntityDataSource.

like image 197
juFo Avatar answered Nov 20 '22 13:11

juFo


See issue Random 'Unable to load one or more of the requested types' Errors (588847):

EntityDataSource will attempt to load all types from all referenced assemblies in order to discover all the entity types of your entity data model.

Using the other answers' technique of making sure all your DLL files are set to "copy local" may help. Otherwise, try their workaround: set the ContextTypeName property of your EntityDataSource to the fully qualified name of your entity container type.

The workaround is what resolved the issue for me.

like image 3
andrej351 Avatar answered Nov 20 '22 13:11

andrej351


I had the same problem and found that it happens because the production environment lacks the correct DLLs. You can set the Copy Local attribute of your project's references to true.

For more info see Error message 'Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.'

like image 2
Mentoliptus Avatar answered Nov 20 '22 14:11

Mentoliptus


I had this same problem today, but only on the production server, not in development or test (figures). I'm still investigating what's going on, but I changed the production server .NET Trust Level to High and the problem went away... This is obviously a temporary fix, but it's better than nothing. I hope this helps.

like image 1
Brandon Zeider Avatar answered Nov 20 '22 13:11

Brandon Zeider