Something Went Wrong System.ArgumentOutOfRangeException At System.Web.HttpCachePolicy.UtcSetLastModified (DateTime utcDate)

Yesterday I set up a new VPS server to test a web application. The application in question required some very obscure testing needing the team to enter data into the website and then move the server clock forwards one month.  We needed to test this over an 18 month period. I set up the server and deployed the latest source code and setup the database and then moved the server clock backwards 18 months.

I checked the application was running and I could log in and everything seemed fine (“seemed” being the operative word). At first the error was not apparent and I just saw a few JavaScript errors being thrown.

My application has code to email me outlining full error details if ever an error is thrown by the application (on came the onslaught of error emails!!!).

Here is the error email.
--------------------------
OFFENDING URL: http://xxxxxxxxxxxxxxx/WebResource.axd?d=k3VKWi2nOWAT61NZMg8SrB_VQstnIoASNgBr5-q6tow1&t=633742757530312500
SOURCE: System.Web
MESSAGE: Specified argument was out of the range of valid values.
Parameter name: utcDate
FORM:
QUERYSTRING: d=k3VKWi2nOWAT61NZMg8SrB_VQstnIoASNgBr5-q6tow1&t=633742757530312500
TARGETSITE: Void UtcSetLastModified(System.DateTime)

STACKTRACE: at System.Web.HttpCachePolicy.UtcSetLastModified(DateTime utcDate)at System.Web.Handlers.AssemblyResourceLoader.System.Web.IHttpHandler
.ProcessRequest(HttpContext context)at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.
HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
REFERER: http://xxxxxxxxxxxxxAddInjection.aspx?PatientId=7714
SESSION VARIABLES : None
--------------------------

After some investigation I found that the application was trying to load an assembly that was created in the future! It seems that .net does not like time travel!

I decided to move the server clock forwards back to the current date and then test month on month by rolling the server clock forward into the future so the assemblies loaded were always dated in the past and that fixed the issue!

Just a quick thank you to Brian Hartsock. The information on your blog was invaluable! http://tinyurl.com/lfsyem

Tweet Me | Link To Facebook