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">


I hope this helps somebody.




  • Thank you for sharing this.

  • Thanks... That's working fine.

  • Thanks you :D
    that do the trick

  • 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 a lot. Solved my problem too!

  • 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 :(

  • 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:


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

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

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

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

Comments have been disabled for this content.