R – Weird ASP.NET (MVC) error: “Unable to load one or more of the requested types.”

asp.netasp.net-mvcnhibernate

I'm getting weird error and I have no idea how to resolve it. I've got an ASP.NET MVC website which works fine but once I publish it to a server I get:

"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.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr
appContext, HttpContext context,
MethodInfo[] handlers) +206
System.Web.HttpApplication.InitSpecial(HttpApplicationState
state, MethodInfo[] handlers, IntPtr
appContext, HttpContext context) +188
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr
appContext, HttpContext context) +295
System.Web.HttpApplicationFactory.GetPipelineApplicationInstance(IntPtr
appContext, HttpContext context) +56
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr
appContext) +231

[HttpException (0x80004005): Unable to
load one or more of the requested
types. Retrieve the LoaderExceptions
property for more information.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext
context) +8889839
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext
context) +85
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest
wr, HttpContext context) +333

I was trying to google some solution but so far have not found anything.
The website has quite a lot of references which is most probably the cause of this problem, however I have no idea how to identify the problematic assembly.
The website runs on a subdomain, root site is also ASP.NET MVC app.

Best Answer

After some investigation I was able to track the problem to (Fluent) NHibernate. It was not able to initialize itself due to security constraints on the server (read Medium Trust). First I tried to update to latest version hoping it would work in medium trust environment. Then I tried to patch it to work and then I just simply gave up and contacted my hosting provider to raise the trust level for the app.

Related Topic