简体   繁体   中英

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

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.

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.

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

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.

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:

  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

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!

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:

  1. Copying local git repo to usb flash disc.
  2. Deleting the local git repo.
  3. Copy & paste the git repo to disc again from usb disc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM