visual-studio 编译错误:刻度必须介于 DateTime.MinValue.Ticks 和 DateTime.MaxValue.Ticks 之间。参数名称:刻度
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2496148/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Compile Error: Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks. Parameter name: ticks
提问by mickyjtwin
I have a Visual Studio 2008 solution that when I build, returns the following error:
我有一个 Visual Studio 2008 解决方案,当我构建时,返回以下错误:
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...
在解决方案中,根本没有对 DateTime.MinValue.Ticks 的引用/使用......
EDIT:
编辑:
There are only 2 references to ticks in my solution, and neither of those are causing the issue.
在我的解决方案中只有 2 个对刻度的引用,并且这些都没有导致问题。
There are no constructor issues with DateTime either. I do not believe it is related to DateTime or ticks at all.
DateTime 也没有构造函数问题。我不相信它与 DateTime 或滴答声有关。
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.
我发现了一个类似的参考,结果证明它是解决方案中损坏的图像文件,它没有日期修改值。不过这不影响我的。
回答by Guffa
The error message comes from the DateTimeconstructor that takes a long value.
错误消息来自DateTime采用 long 值的构造函数。
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.
在您的代码中的某个地方,您正在从一个常量值创建一个 DateTime 值,以便实际创建是在编译时而不是运行时完成的。该值超出了构造函数的范围。
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.
但是,异常发生在运行时。为了在编译时获得它,您的标记代码中可能有一些东西,例如服务器控件中的参数值。
回答by rtpHarry
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
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
- 切换到输出选项卡,看看最后一个文件夹是什么,它是在它borked 之前编译的。
- 删除那个文件夹。
- 重新编译
- 不断重复步骤 1 到 3,直到网站编译完成
- 当它编译时开始带回您删除的最后一批中的单个文件,直到找到有问题的文件
回答by ChrisF
It sounds like you're not initialising ticks.
听起来你没有初始化ticks.
In that case there won't be a reference to DateTime.MinValue.Ticks.
在这种情况下,将不会引用DateTime.MinValue.Ticks.
You'll have to search for ticksand double check all occurrences.
您必须搜索ticks并仔细检查所有出现的情况。
回答by Ankit Agrawal
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
这篇文章应该可以让您重回正轨,而无需花费数小时挠头。 http://runtingsproper.blogspot.com/2010/03/solved-error-1-ticks-must-be-between.html
回答by Gurer Onder
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:
我在 Visual Studio 2013 中遇到了同样的错误。正如你所说,没有 Ticks 或类似的东西。但是前段时间,我的计算机上出现了一个日历问题,日期是 2199 或类似的东西,我意识到在那次错误之后我没有运行代码。我的解决方案是:
- Copying local git repo to usb flash disc.
- Deleting the local git repo.
- Copy & paste the git repo to disc again from usb disc.
- 将本地 git repo 复制到 USB 闪存盘。
- 删除本地 git 存储库。
- 将 git repo 从 USB 光盘复制并粘贴到光盘。
回答by hammerpath
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!
我用 rtpHarrys answear 解决了这个问题。结果发现我有一个日期格式错误的 .ttf 文件,所以我重新保存了它,现在它可以工作了!

