Home Dashboard Directory Help
Search

Unable to load one or more of the requested types. Connected with EntityDataSource by Tomáš Kubík


Status: 

Active


28
0
Sign in
to vote
Type: Bug
ID: 541962
Opened: 3/15/2010 4:40:31 AM
Access Restriction: Public
11
Workaround(s)
view
24
User(s) can reproduce this bug

Description

Hello,

I use ASP.NET 4.0 + Net Framework 4.0 RC + EntityFramework (with Visual Studio 2010 professional)
I have a trouble with your component EntityDataSource ... every page which contains this component (EntityDataSource) has (in 90% - its not 100%) BUG after compiling and loading to server (WS2008,IIS 7.5,NF4.0RC without VS2010) .... Its interesting that I run directly debug mode (and server) in Visual Studio .... everything is fine ...no bugs ... only after compiling (but without compiling too) loading this website to server, where is only net framework 4.0RC without VisualStudio 2010 ... every page witch contains EntityDataSource report this bug :

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

[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.Assembly.GetTypes() +143
System.Data.Metadata.Edm.ObjectItemConventionAssemblyLoader.LoadTypesFromAssembly() +46
System.Data.Metadata.Edm.ObjectItemAssemblyLoader.Load() +34
System.Data.Metadata.Edm.AssemblyCache.LoadAssembly(Assembly assembly, Boolean loadReferencedAssemblies, ObjectItemLoadingSessionData loadingData) +130
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) +248
System.Data.Metadata.Edm.ObjectItemCollection.LoadAssemblyFromCache(ObjectItemCollection objectItemCollection, Assembly assembly, Boolean loadReferencedAssemblies, EdmItemCollection edmItemCollection, Action`1 logLoadMessage) +580
System.Data.Metadata.Edm.ObjectItemCollection.ExplicitLoadFromAssembly(Assembly assembly, EdmItemCollection edmItemCollection, Action`1 logLoadMessage) +193
System.Data.Metadata.Edm.MetadataWorkspace.ExplicitLoadFromAssembly(Assembly assembly, ObjectItemCollection collection, Action`1 logLoadMessage) +140
System.Web.UI.WebControls.EntityDataSourceView.ConstructContext() +756
System.Web.UI.WebControls.EntityDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +86
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +28
DevExpress.Web.ASPxClasses.Internal.DataContainer.PerformSelect() +181
DevExpress.Web.ASPxClasses.ASPxDataWebControlBase.DataBind() +281
Basket.Wizard_NextButtonClick(Object sender, WizardNavigationEventArgs e) +234
System.Web.UI.WebControls.Wizard.OnBubbleEvent(Object source, EventArgs e) +586
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +52
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3691
Details
Sign in to post a comment.
Posted by d_m2 on 2/24/2014 at 9:11 AM
Hi All,

I'm try to install a windows services, my project does not use any aditional reference just usign .Net system references like this:
adodb
Microsoft.CSharp
System
System.Configuration
System.Configuration.Install
System.Core
System.Data
System.Data.DataSetExtensions
System.Managment
System.ServiceProcess
System.Xml
System.Xml.Linq


Still having the same problem:

Error 1001. Error 1001. Unable to get installer types in the directory\project.exe assembly. --> Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

Using VisualStudio 2010

Trying to install the windows service in the same machine the project was coded and built for test.

Posted by devweb693 on 12/16/2013 at 2:28 AM
Clean and rebuild the solution if necessary add the required dll's this solution worked for me
Posted by VamsiM on 12/14/2012 at 10:01 AM
I was able to resolve it by assigning a context upon its creation, i.e. ContextCreating event

protected void EntityDataSource1_ContextCreating(object sender, EntityDataSourceContextCreatingEventArgs e)
        {
            EntityMode1 db = new EntityMode1();
            e.Context = (db as IObjectContextAdapter).ObjectContext;
        }
Posted by JiyaDesai on 8/30/2012 at 8:23 PM
I was using EntityDataSource and this problem was not there initially, The Problem started after i used Microsoft Report Viewer in the project.

I did as described by Sam.P.C of copying System.Data.Entity.dll and System.Web.Entity.dll into bin folder.
but that still did not worked.

Then Compiling and Deploying Project into "Release" mode Solved my issue. at this point i do have all required Microsoft Report Viewer DLLs and DLLs recommended by Sam.P.C in the bin folder.

What solved the problem, I am not sure, I have spend endless time to resolve this and now since its working, I do not want to do any experiment further.

But I a really annoyed by MSFT post saying "The bug is fixed in .NET Framework 4.5.", ... SO ? what about 4.0 users?
The Post should also say recommended fixes or patch to download which fixes the same in 4.0.    The MSFT Post is very unprofessional.

Posted by Microsoft on 4/23/2012 at 5:20 PM
This is a duplicate of connect bug 588847 (https://connect.microsoft.com/VisualStudio/feedback/details/588847).
The bug is fixed in .NET Framework 4.5.
Posted by kiran kumar jaghni on 4/18/2012 at 8:23 AM
Hello,

I have same issue with .Net framework 4.0.Strange about issue is it didn’t appear during development.
When the code was promoted into production, it appeared. Below is the log of the issue

Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information." stacktrace=" at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)     at System.Reflection.RuntimeModule.GetTypes()     at System.Reflection.Assembly.GetTypes()     at System.Data.Metadata.Edm.ObjectItemConventionAssemblyLoader.LoadTypesFromAssembly()     at System.Data.Metadata.Edm.ObjectItemAssemblyLoader.Load()     at System.Data.Metadata.Edm.AssemblyCache.LoadAssembly(Assembly assembly, Boolean loadReferencedAssemblies, ObjectItemLoadingSessionData loadingData)     at 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)     at System.Data.Metadata.Edm.ObjectItemCollection.LoadAssemblyFromCache(ObjectItemCollection objectItemCollection, Assembly assembly, Boolean loadReferencedAssemblies, EdmItemCollection edmItemCollection, Action`1 logLoadMessage)     at System.Data.Metadata.Edm.ObjectItemCollection.ExplicitLoadFromAssembly(Assembly assembly, EdmItemCollection edmItemCollection, Action`1 logLoadMessage)     at System.Data.Metadata.Edm.MetadataWorkspace.ExplicitLoadFromAssembly(Assembly assembly, ObjectItemCollection collection, Action`1 logLoadMessage)     at System.Data.Metadata.Edm.MetadataWorkspace.LoadFromAssembly(Assembly assembly, Action`1 logLoadMessage)     at System.Web.UI.WebControls.EntityDataSourceView.ConstructContext()     at System.Web.UI.WebControls.EntityDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments).

Here is the RCA done by me:
When the code was promoted into prod server (win server 2003,IIS 6.0) for the first day there was no issue, the issue started on second day. This is strange to me and I was supposed to bring prod up immediately, had to stop App Pool, clean Asp.Net Temporary files in 4.0 frame work folder, start App Pool, it worked again. Then I started investigating the issue, the issue occurs when App Pool is recycled automatically by IIS, also in other the server it occurs when the App Pool is shut down IIS. Then I changed App pool settings not recycle and not to shut down, and the application is not crashing.

Conclusion:
This issue occurs specially for those web apps which use entity frame work and entity data sources in their application. The issue could be with following dlls
•    System.data.entity
•    System.data.entity.desin
•    System.web.entity
•    System.web.entity.desingn
These dll are not properly loaded or not picked when the app pool is recycled. For this reason the Asp.net 4.0 Run time cache has to be deleted manually.

The actual problem is with the Microsoft .Net frame work 4.0 dlls provided in VS2010.When I observed the referenced dlls in VS2010 from C:\Program Files\Reference Assemblies\Microsoft\Framework\Net Framework\v4.0 are differed from frame work dlls C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319 there is significant change.

My request to MS team is to provide clarifications/answers why is this behavior and when this will be fixed, if this resolved please provide the details of fix.

Thanks
Kiran



Posted by LuizFredericoJr on 10/28/2011 at 2:54 AM
If you is using the EntityDataSource in your project, this is the solution... ( http://weblogs.asp.net/kencox/archive/2011/06/08/fix-unable-to-load-one-or-more-of-the-requested-types-errors.aspx?CommentPosted=true#commentmessage )

' you should set the ContextTypeName="ProjectNameNameSpace.EntityContainerName" '

This solve my problems...

Posted by Sameer PC on 8/8/2011 at 1:49 AM
Again i had the same issue. this time with "Web Site Project" (earlier it was wtih Web Application)
after hours of experimentation the deployment worked... not sure this is the reason!

When i published the Web site the size of these files are as follows
System.Data.Entity.dll         1640 KB
System.Web.Entity.dll         63 KB

But if you check the Microsoft.NET\Framework\v4.0.30319 folder the size of the files are as follows;

System.Data.Entity.dll         4360 KB
System.Web.Entity.dll         135 KB


Copied these files on the deployment folder and the application worked fine !!!




Posted by Sameer PC on 8/4/2011 at 12:29 AM
Another issue could be the assembly version specified in the web.config and the actual assembly in your bin folder. try to remove the references or make sure that both versions are correct.
Posted by DrWeb86 on 7/18/2011 at 6:46 AM
Please Microsoft Guys!

Could you also instead of showing message LoaderException - show actual problem message?
Posted by Eric Rohlfs on 4/10/2011 at 10:37 AM
I had the same issue on a 64 bit machine. Cleaning the solution and rebuilding fixed it for me.
Posted by Andy Rive ra on 3/28/2011 at 2:21 PM
After 5 hours of dealing with this problem I got it working. I tried everything suggested by everyone on this connect ticket and the other one. The thing that finally solved it was setting all my referenced assemblies to “copy local = true”. If I copy every dll including system ones such as system.data.entity.dll etc into the bin folder it works. If any dll reference is missing it stops working. My scenario was a win7 64bit development workstation where everything worked fine using VS2010 and IIS. Then when copied to a windows 2003 server standard edition with IIS 6 it would not work. Both computers have the latest versions of the OS updates etc.

Hope this helps you!
Posted by Microsoft on 2/21/2011 at 11:17 PM
Hi all,

So far investigation of this issue has led to multiple causes. In the default configuration, EntityDataSource will attempt to load all types from all referenced assemblies in order to discover all the entity types of your entity data model. If a type cannot be loaded (e.g. for the causes Jeff mentioned earlier, or for some security issue, or any of the dependencies of the type cannot be found, or if the type is incompatible with the current version of the CLR), then you will get this exception.

The original cause is likely external to the EntityDataSource, but the EntityDataSource reveals the problem because it eagerly tries to load all types. You might be able to repro the issue by running code like this in your application:

foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
{
    asm.GetTypes();
}

And this could help you identify what is the type that cannot be loaded and fix it.

In addition to this, a good option that usually works is to set the ContextTypeName of the EntityDataSource to the type name of your derived ObjectContext class. This turns off the mechanism that scans all assemblies for entity types.

In a future version we might change the EntityDataSource to be more resilient to this kind of failure, but this would have the disadvantage of ignoring legitimate failures.

We are using a separate Microsoft Connect issue (http://connect.microsoft.com/VisualStudio/feedback/details/588847/random-unable-to-load-one-or-more-of-the-requested-types-errors) to track the improvement in the future, so this bug will be resolved as a duplicate.

Thanks,

Diego Vega
Entity Framework Team
Posted by Eric Microogle on 2/8/2011 at 10:08 PM
Amend:I tried it on 2 win 2008 64bit server, both get this error. but on my win 7 32bit develop pc, it works fine.
not very sure, but it seamed that it is related to 64 bit?
Posted by Eric Microogle on 2/7/2011 at 10:05 AM
delete and re-add in some dlls in bin, can resolve, but when the app was recycling(or restart, or iis restart), the error happened again.

reproduce on my dev machine (win7) too, just in iis app pool, right click your app, and click recycling.... refresh your web page, the error shows up.

Could MS solve this ASAP? Seams that it's a real bug.
Posted by Eric Microogle on 2/7/2011 at 9:37 AM
I log ouit ReflectionTypeLoadException detials and get many errors like, Could not load file or assembly 'System.ServiceModel.DomainServices.EntityFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

I did not even refer these dlls. the one above is for silver light.

win server 2008 r2 64bit .net fra4
Posted by VADK on 12/31/2010 at 2:15 AM
I also had the same error. Then I caught it (as ReflectionTypeLoadException) and examined the LoaderExceptions property. It said that it cannot load System.ServiceModel.DomainServices.EntityFramework.dll, so I set CopyLocal for it. That helped.

As far as I see, the DLLs can be different, you just need to catch ReflectionTypeLoadException, examine LoaderExceptions, and do something that the site can load the DLLs.

Additionally I would say that this is something wrong with the server software. Because I kept getting the error only on a particular server. Maybe the different versions of .NET were installed incorrectly…
Posted by Picky Martin on 10/28/2010 at 10:28 AM
It turned out that our web project should no longer have a dependency on Unity libraries. The project was looking for Microsoft.Practices.Unity.dll because there were some orphant Unity libraries (ie. Microsoft.Practices.Unity.Configuration.dll) left in the bin directory (which I thought would be cleared when I ran 'Clean' on the solution). Anyhow, the issue went away after we removed all Unity libraries in the bin directory. I haven't spent the time to figure out why the application would try to load Unity.dll when a web control calls the DataBind() method while having reference to some Unity libraries in the bin directory.

Thanks,
Martin
Posted by Picky Martin on 10/26/2010 at 5:26 PM
I didn't have any luck binding the datasource at runtime as suggested by tkrusz; however, I was able to see more details about the LoaderExceptions, which says:

{"Could not load file or assembly 'Microsoft.Practices.Unity, Version=2.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.":"Microsoft.Practices.Unity, Version=2.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"}

So I grabbed Unity v2.0 from http://www.microsoft.com/downloads/en/details.aspx?FamilyId=2d24f179-e0a6-49d7-89c4-5b67d939f91b&displaylang=en, and included the missing dll in the reference, and it seems to fix the problem.
Posted by tkrusz on 7/27/2010 at 3:45 PM
I am also having the same issue described above. Through additional testing I've discovered that this only happens when the datasource is bound via the .aspx page but works fine when bound via the .cs code. This prevents me from using the automatic insert, updates and deletes which make the datasource so efficient.

<asp:EntityDataSource ID="edsVendors" runat="server" ConnectionString="name=ProNetData"
                        DefaultContainerName="ProNetData" EnableDelete="False" EnableUpdate="False" EntitySetName="VendorDetails"
                        Include="Vendor,VendorService,Client" AutoGenerateWhereClause="true">
                        <WhereParameters>
                            <asp:ControlParameter ControlID="ddlClientName" Name="ClientID" Type="Int32" ConvertEmptyStringToNull="true" />
                            <asp:ControlParameter ControlID="ddlVendorName" Name="VendorID" Type="Int32" ConvertEmptyStringToNull="true" />
                            <asp:ControlParameter ControlID="ddlServiceName" Name="VendorServiceID" Type="Int32"
                                ConvertEmptyStringToNull="true" />
                            <asp:ControlParameter ControlID="ddlVendorType" Name="AssessmentOnly" Type="Boolean"
                                ConvertEmptyStringToNull="true" />
                        </WhereParameters>
                    </asp:EntityDataSource>
Posted by dgcoffman1 on 7/6/2010 at 2:16 PM
Adding a me-too comment. Details at http://serverfault.com/questions/157960/unable-to-load-type-error-in-asp-net-4-application-on-windows-server-2003-iis6

Nearly identical exception and stack trace except I'm on IIS6. In my case, the app works fine until the first application pool worker process recycle, then fails with this error every time.
Posted by timvdh on 6/25/2010 at 6:59 AM
I tried all provided workarounds to no avail. Sometimes, after closing all windows and "Rebuild All" the web project will start debugging, but usually I receive the same message reported here. My website project uses DLL projects in the same solution. I am binding to code beside objects for now.
Posted by Tomáš Kubík on 3/17/2010 at 11:45 AM
Pls, can you tell me how can i read the LoaderException without debugger and visual studio .... i tried catch a Application_Error in global.asax but it didnt work.... Because the server hasnt got Visual Studio .... and i dont want to install it on the server (=> no results , i think it would be the same like on my desktop in debug mode => without problems). Is any options how can i catch this exception in IIS 7.5?

1) i cant find "Generate serialization assembly" options in Visual Studio 2010 RC
2) Im not using a derived types ...
3) Its a bit different issue ... I have a problem exactly with "EntityDataSource" component .... its not my dll (i think its System.Data.Entity.dll or System.Web.Entity.dll) ... this file are not in my bin directory ... If i remove all EntityDataSource from my project ... everything works 100% correctly....

I cant understand why I must enable or disable any options,features and so one .. for correctly working EntityDataSource while e.g. the SqlDataSource works fine without it :) ....
My entity model is ok too. Work with it on codebehind is without problems ...

P.S : Operation system of the server and NetFramework has been reinstalled .... the bug is still here.
Posted by Microsoft on 3/17/2010 at 9:27 AM
We are still investigating this issue, but there are a variety of things that could be causing this:

1. An option in web site projects in retail mode (see http://forums.asp.net/p/1062686/1529552.aspx for details).

2. Are you using derived types where the base type of your entity is in another assembly? Is it possible that assembly is not reachable (either not GAC'd or not in the same directory as your other assemblies)?

3. Do you have indexing turned on? It's possible this is causing an issue (see http://geekswithblogs.net/pavelka/archive/2006/02/19/VisualStudio2005RetrieveTheLoaderExceptionsPropertyForMoreInformation.aspx for details).

Jeff

Posted by Microsoft on 3/17/2010 at 9:14 AM
Can you provide the information in the LoadersException and send me a repro at: jeffders @ microsoft.com ?

Thanks,
Jeff
Posted by Microsoft on 3/16/2010 at 1:12 AM

Thanks for your feedback.

We are routing this issue to the appropriate group within the Visual Studio Product Team for triage and resolution.
These specialized experts will follow-up with your issue.
Posted by Tomáš Kubík on 3/15/2010 at 4:45 AM
Add : my desktop where its fine is W7 .... I didnt mix debug and release version of files (dll..) on server ...... And i wanna say " Its interesting that I run directly debug mode in Visual Studio .... everything is fine " without "(and server)" ...sorry
Sign in to post a workaround.
Posted by VamsiM on 12/14/2012 at 10:02 AM
I was able to resolve it by assigning a context upon its creation, i.e. ContextCreating event

protected void EntityDataSource1_ContextCreating(object sender, EntityDataSourceContextCreatingEventArgs e)
        {
            EntityMode1 db = new EntityMode1();
            e.Context = (db as IObjectContextAdapter).ObjectContext;
        }
Posted by João Verisssimo on 7/28/2011 at 10:51 AM
pt-br: Eu resolvi meu problema definindo a propriedade ContextTypeName do EntityDataSource, para o meu contexto de Entity, após isso funcionou blz!

en: I solved my problem by setting the ContextTypeName of EntityDataSource to my context of Entity, after it worked ok!

----ContextTypeName="CineFloripa.WebData.cinefloripaEntities"----

<asp:EntityDataSource ID="EntityDataSource1" runat="server"
        ConnectionString="name=cinefloripaEntities"
        DefaultContainerName="cinefloripaEntities" EnableFlattening="False"
        EntitySetName="vw_filmes"
        ContextTypeName="CineFloripa.WebData.cinefloripaEntities"
        Select="it.[Audio], it.[Classificacao], it.[CategoriaNome], it.[Duracao], it.[FilmeId], it.[ImagemId], it.[Nome], it.[NomeUrl], it.[EmCartaz], it.[TwitterHashtags]">
    </asp:EntityDataSource>

Posted by Sameer PC on 7/12/2011 at 10:22 PM
Delete bin and obj folder, Rebuild the solution and deploy it !
Posted by Zacharydl on 2/5/2011 at 2:59 PM
Try doing what the message says by displaying the LoaderExceptions in your Global.asax file. I followed these instructions from Ken Cox:

http://weblogs.asp.net/kencox/archive/2010/08/24/fed-up-with-system-data-metadata-edm-objectitemassemblyloader.aspx
Posted by easten_20 on 12/20/2010 at 7:50 PM
try to remove unnecessary reference from your app. such as, wpf, silverlight, etc.

the problem somehow occured when i using those reference, after i remove those reference my app work smoothly.

the other work around is not to use entitydatasource, just bind the control from code behind.

hope this help.
Posted by JeffMartin on 11/5/2010 at 2:06 PM
I was having this too and I think it has gone away. Here are the things I did which may or may not be relevant.

I currently (on the working page) have 3 EntityDataSources. This is on a page with a grid view that has one. Then the edit template of one column has a drop down list and the footer also has a drop down list that lists the same data. These are linked to two different EntityDataSources, even though they display the same information. The one in the edit template has the EDS in the edit template too.

I haven't seen the error since I gave each of my dropdown's its own EDS (even tho they query the same thing.)
Posted by DamPee on 11/5/2010 at 7:57 AM
I was using the XtraReport controls from DevExpress. I added the XtraEditors Dll this DLL where not automatically added when adding a report to the project!
Posted by Oleg_Petrychenko on 11/1/2010 at 3:00 PM
I use EntityFramework 4.0+EntityDataSource+RadGrid on my pages and I got "Unable to load one or more of the requested types" in 90% cases if the application runs first time after build and 99% if the application is working some time. Moreover I got the same behavior on local workstation and on DEV server. After removing EntityDataSources from pages the issue has been gone. Looks like the issue related to EntityDataSource.
Posted by Michal Zalewski on 6/28/2010 at 6:41 AM
I installed ADO.NET Data Services v1.5 CTP2 (http://www.microsoft.com/downloads/details.aspx?FamilyID=a71060eb-454e-4475-81a6-e9552b1034fc&displaylang=en#filelist) and it work!
Posted by DTape85 on 5/19/2010 at 7:54 AM
I was just having this same problem. It seems when I use the EntityDataSource and refer to an entity model in a .dll I am getting this error. However, the problem did not occur again after I went to Build>Configuration Manager and switched each project from "Debug" to "Release" in the configuration column.
Posted by Tomáš Kubík on 3/15/2010 at 8:03 AM
dont use EntityDataSource :)