We are seeing some strange errors on our asp.net webform sites. The sites are compiled successfully and deployed to our prod servers where they start and run without any problems.
Every morning at around 3AM we restart the application pool and here is where the mystery begins. Occassionally, let's say about one out of three times, after the restart we get the error below. The affected aspx page differs from time to time (the unaffacted aspx pages work just fine).
System.BadImageFormatException: [C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\f7681018\abf51a9e\App_Web_xegahzdu.dll] A valid typedef or typeref token is expected to follow a ELEMENT_TYPE_CLASS or ELEMENT_TYPE_VALUETYPE.
at ASP.startpagetemplate_aspx.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
We have four servers in a load balanced environment and the error appears on different servers and (as stated before) on different aspx pages. I have tried to read up on the exception, but the cases I read about differ from our case as they occur instantly. Our site builds and starts fine. The error appears after an application pool restart but, notably, not after every restart.
Would be grateful for any suggestions on what to look for.