SOLVED: Error 1 Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks

This is a simple looking error message that is deceptively hard to track down. Thankfully if you're having this problem then this article should get you back on track without spending hours scratching your head.


It was time to update an existing website so after synchronising my copy of the site with the server I was ready to make my changes. The only problem was that every time I tried to compile the site I was getting an error:

Error 1 Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks. Parameter name ticks

This was a hard error to deal with because doing a project wide search for "Ticks" revealed no results. Searching for the DateTime object was similarly unproductive - only a handful of references and mostly within auto-generated code inside my linq to sql data context.

The most difficult element of this puzzle was that the error listed in the Errors tab wasn't linked to a line of code in the project - double clicking it did nothing!

How I Solved It

After getting pretty annoyed because I was on the clock I made a backup of the site and decided to delete files until the dodgy file showed its face.

I used the following heuristic to do this:

  1. Switch to the Output tab and see what the last folder was which was compiled before it borked.
  2. Delete that folder.
  3. Recompile
  4. Keep repeating steps 1 to 3 until the site compiles
  5. When it compiles start bringing back individual files in the last batch you deleted until you find the offending file

For me it turned out to be a single .jpg which when viewed in explorer with View Details had an empty "Date Modified".

I opened it up in Photoshop and saved it out again and this fixed the problem.

Will this work for you?

I was lucky that the files I deleted were all in supporting folders and didn't contain class files which would have broken the compilation of the site. If it turns out that step 1 leads you to a folder such as this I would take a look at the files and check that there aren't any obviously dodgy files. If there aren't then try deleting all of the non essential files in the site and see if the compiler is really getting hung up on that folder or not.

Also when I first had this problem I went to Google and found that I had visited pages on sites that mentioned this error code before. I don't know how I solved i the first time but I am pretty sure this wasn't the solution so you might find your problem remains unsolved even after following this guide!

kick it Shout it vote it on

1 comment :

Farschidus said...

You have saved a lot of time for me,
Thank you and good luck