What could cause a TypeLoadException from an auxiliary assembly in an ASP.NET website in one environment, but not another? Here's what I have:
- Company.Web, a .NET class library; references System.Web 4.0
- Company.Web contains some
HttpResponse
extension methods - Company.Web contains a
MediaRequestHandler
(: IHttpHandler
) that references myHttpResponse
extensions, plusHttpContext
and related classes - Company.UI, an ASP.NET WebForms application assembly; references System.Web 4.0 and Company.Web
- Those references in both projects are
<Reference Include="System.Web" />
- MediaRequestHandler configured as shown below
- Server ABC, with site 1 and site 2 in IIS
- DEV branch, from where I built this code to Server ABC, site 1
- MAIN branch, to where I merged this code en mass, and from where I built to Server ABC, site 2
- These are Sitecore sites.
This works on site 1, but I am getting a TypeLoadException
in site 2 when it tries to invoke my MediaRequestHandler
. There aren't many details in the exception (below). I ran fuslogvw on the server with failures logged and saw nothing; I ran it with everything logged and saw a 'successful partial load' on Company.Web. The latter appears to be normal behavior; certainly the assembly is loading because everything else in it works.
The bullets above are areas where I suppose I may have messed something up, but I've checked the merge and the basic site configs, and I can't see any differences. My next step is a deep dive into configuration compares, but meanwhile, can anyone can provide suggestions on where to focus my investigation?
The config:
<system.webServer>
<handlers>
<add verb="*" path="sitecore_media.ashx" type="Company.Web.Media.MediaRequestHandler, Company.Web" name="Company.MediaRequestHandler" />
...
<system.web>
<httpHandlers>
<add verb="*" path="sitecore_media.ashx" type="Company.Web.Media.MediaRequestHandler, Company.Web" />
The exception:
Exception information:
Exception type: TypeLoadException
Exception message: Could not load type 'Company.Web.Media.MediaRequestHandler' from assembly 'Company.Web'.
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)
at System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase)
at System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase)
at System.Web.Configuration.HandlerFactoryCache.GetTypeWithAssert(String type)
at System.Web.Configuration.HandlerFactoryCache.GetHandlerType(String type)
at System.Web.Configuration.HandlerFactoryCache..ctor(String type)