Fix: 'Unable to load one or more of the requested types' Errors

A long time ago, I reported on an intermittent ‘Could not load file or assembly‘ bug where ASP.NET 4 was encountering a bizarre error on start-up in System.Reflection.RuntimeModule.GetTypes(RuntimeModule module). I neglected to post a follow-up here.

The workaround is to always set the ContextTypeName property in your EntityDataSource. That is,  you should set the  ContextTypeName="ProjectNameNameSpace.EntityContainerName"

Here's an example of some mark-up:

<asp:EntityDataSource ID="edsCategoryTypesFilter" runat="server" ConnectionString="name=OfficeBookDBEntities1"
ContextTypeName="OfficeBook.OfficeBookDBEntities1" DefaultContainerName="OfficeBookDBEntities1"
OrderBy="it.CategoryName" EntitySetName="AccountTypeCategories" EntityTypeFilter="AccountTypeCategories">
</asp:EntityDataSource>

 

I hope this helps somebody.

 

Ken

Comments

# re: Fix: 'Unable to load one or more of the requested types' Errors

Tuesday, August 16, 2011 2:21 AM by TATWORTH

Thank you for sharing this.

# re: Fix: 'Unable to load one or more of the requested types' Errors

Friday, October 28, 2011 5:32 AM by Luiz Frederico Jr. (Brasil - São Paulo)

Thanks... That's working fine.

# re: Fix: 'Unable to load one or more of the requested types' Errors

Tuesday, November 8, 2011 1:21 PM by mario

Thanks you :D

that do the trick

# re: Fix: 'Unable to load one or more of the requested types' Errors

Sunday, January 15, 2012 10:35 AM by John K.

Thank you so much for posting this. I had the identical problem going from dev to prod env.  Would have never figured this one out without your help.

Thanks!

# re: Fix: 'Unable to load one or more of the requested types' Errors

Friday, February 17, 2012 9:06 AM by Simon

Thanks a lot. Solved my problem too!

# re: Fix: 'Unable to load one or more of the requested types' Errors

Tuesday, February 28, 2012 7:45 AM by Farrel

How would I fix this inside a console?

I've got a console app that uses the dbContext to write data away and I get this error :(

# re: Fix: 'Unable to load one or more of the requested types' Errors

Sunday, April 1, 2012 2:21 PM by daveharney

Praise be to Ken!!

This was a nightmare for me.  I was about to re-write my site without EF - which would be a ton of work.  I've just tried your fix, so will have to see if the error does pop up again.

However, this is the first time I've been able to set my config to custom errors "On" and debug to "false" - and NOT get that miserable error.

I'm pretty much a novice and perhaps everyone else knows that you have check the namespace name to get this fix right.  As one of my EFs goes against the ASPNETDB membership stuff, here is how my entry looks:

ContextTypeName="ASPNETDB.MDFModel.ASPservicesEntities"

I've got my fingers crossed, but I hope this nightmare is over.

# re: Fix: 'Unable to load one or more of the requested types' Errors

Sunday, July 22, 2012 7:17 PM by bebas

Thanks A LOOOOOOOOOOOOOOOT :)

I was becoming crazy... but may you tell us how you found the solution ? Thanks again

# re: Fix: 'Unable to load one or more of the requested types' Errors

Saturday, September 8, 2012 3:51 AM by Kevin Mortimer

This issues has been causing me problems for months.. and you have just fixed it.. fantastic!

# re: Fix: 'Unable to load one or more of the requested types' Errors

Monday, August 19, 2013 4:16 AM by Larry

Great! you solved the issue. Thanks a lot!!

Thanks for sharing your feedback! If your feedback doesn't appear right away, please be patient as it may take a few minutes to publish - or longer if the blogger is moderating comments.

Leave a Comment

(required) 
(required) 
(optional)
(required)