问题
I have a Visual Studio 2008 solution that when I build, returns the following error:
Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks. Parameter name: ticks
There is no reference file/line/column in the error. Becoming quite frustrating as the solution builds in the end, however I cannot debug.
In the solution, there is no reference/using to DateTime.MinValue.Ticks at all...
EDIT:
There are only 2 references to ticks in my solution, and neither of those are causing the issue.
There are no constructor issues with DateTime either. I do not believe it is related to DateTime or ticks at all.
I have found a similar reference where it turned out to be a corrupt image file in the solution, where it did not have a date-modified value. This is not affecting mine though.
回答1:
The error message comes from the DateTime constructor that takes a long value.
Somewhere in your code you are creating a DateTime value from a constant value, so that the actual creation is done at compile time rather than runtime. That value is out of range for the constructor.
Code like this gives the same exception:
public static DateTime startTime = new DateTime(-1);
However, the exception happens at run time. To get it at compile time there is probably something in your markup code, like an argument value in a server control.
回答2:
It sounds like you're not initialising ticks.
In that case there won't be a reference to DateTime.MinValue.Ticks.
You'll have to search for ticks and double check all occurrences.
回答3:
I don't know if you have ever solved this but I have found that it has occurred due to glitches in the meta data for images.
It has happened in two different projects, created by two different systems, but the culprit has been missing file modified data for images.
I have written a post about this:
http://runtingsproper.blogspot.com/2010/03/solved-error-1-ticks-must-be-between.html
But the basic crux is of the article is to do the following:
- Switch to the Output tab and see what the last folder was which was compiled before it borked.
- Delete that folder.
- Recompile
- Keep repeating steps 1 to 3 until the site compiles
- When it compiles start bringing back individual files in the last batch you deleted until you find the offending file
回答4:
This is a simple looking error message that is deceptively hard to track down.
it's a compile time error. i also got this error. To Get rid this error ....i opened my file
proximanova-black.ttf in notepad and saveas . this resolved my error.
this article should get you back on track without spending hours scratching your head. http://runtingsproper.blogspot.com/2010/03/solved-error-1-ticks-must-be-between.html
回答5:
I solved the problem with rtpHarrys answear. It turned out I had a .ttf-file with the wrong date format so I just resaved it, and now it works!
回答6:
I experienced the same error in Visual Studio 2013. As you said there were no Ticks or something like that. But accidently some time ago I had a calendar problem on my computer that the date was 2199 or something like that and I realized that after that error I haven't run the code. The solution for me was:
- Copying local git repo to usb flash disc.
- Deleting the local git repo.
- Copy & paste the git repo to disc again from usb disc.
来源:https://stackoverflow.com/questions/2496148/compile-error-ticks-must-be-between-datetime-minvalue-ticks-and-datetime-maxval