德尔福“EClassNotFound”错误,以及损坏的DFM可能性(Delphi “EClassNotFound” errors, and corrupted DFM possibility)
我在Delphi 2007项目中收到了一系列“EClassNotFound”错误。 看起来似乎不是由于缺少名称属性值而导致的,尽管在初始化部分中添加RegisterClass(XXX)修复了手头的EClassNotFound错误,但另一个似乎无限期地遵循了它。
我终于在文本编辑器中打开了DFM文件,它看起来可能会损坏(在表单元素名称中有很多非ASCII字符,而且与我以前在DFM文件中看到的相比,非常“非结构化” )。 (我会在这里发表相同的内容,但不知道这是否正确,w /非aSCII,所以会延期)。
表单加载正常,似乎也编译/语法检查也行,但一旦我运行它,麻烦。
回到SVN的早期版本,看起来它已经处于这种状态一段时间了,这让我认为A)DFM文件不是我的问题,或者B)Delphi格式流是相当错误的 - 容忍/强大(奖金问题:这是什么?)。
如果DFM文件存在问题并且已损坏,则回滚将不得不成为回退途径,而这会很昂贵。 鉴于IDE仍然可以加载它,是否有任何可以清理文件的实用工具?
或者,我完全脱离DFM作为主要嫌疑犯吗?
谢谢大家的意见。 忘了带DFM文件的二进制/文本选项,这很有帮助。 它看起来像DFM本身没有损坏。
尽管如此,仍然有EClassError问题。 re:它缺少属性值,或者引用不存在的属性等等,还有一个问题:这个类是否给出错误(目前为TnxSqlUpdateObject,但如果经验到此为止,可能更多地等待)通常是/总是实际的“罪魁祸首”类/对象?
例如,现在我的主窗体有四个对TnxSqlUpdateObject的引用,w /实际上放在窗体上。 如果我将RegisterClass(TnxSqlUpdateObject)放入初始化部分,它可以很好地运行该EClassNotFound错误,然后继续下一个(在这种情况下,TStringField)。
在这种情况下,我重新安装了NexusDB组件,并使用我认为可能是问题的某些组件构建了一个新项目。 它编译并运行良好,直到我从我的真实项目中添加这个其他表单(反过来,不幸地引用了其他几个)。
所以,这听起来像我真正的问题是如何有条不紊地诊断和修复任何和所有EClassNotFound错误?
I am getting a cascading set of "EClassNotFound" errors in in my Delphi 2007 project. Doesn't seem to be caused by the missing Name property value as often is the case, and though adding RegisterClass(XXX) in the initialization section(s) fixes the EClassNotFound error at hand, another one follows it seemingly indefinitely.
I finally cracked open the DFM file in text editor, and it looks likely corrupted to me (lots of non-ASCII characters amidst form element names, and very "unstructured" looking when compared to what I'm used to seeing in a DFM file). (I'd post a same here but not sure that's OK, w/the non-aSCII, so will hold off).
The form loads fine, and seems to compile / syntax check OK too, but once I run it, trouble.
Going back to early versions of it in SVN, it looks like it's been in this state for some time, which makes me think that either A) the DFM file isn't my problem, or B) the Delphi form-streaming is quite fault-tolerant/robust (Bonus Question: Which is it?).
If the DFM file is the problem, and is corrupted, rolling back will have to be a roll-back WAY back, and that's gonna be expensive. Given that the IDE can still load it, is there any utility that can clean up the file?
Or, am I totally off base w/the DFM as primary suspect?
Thanks folks for the input. Forgot about the binary/text options w/DFM files, so that was helpful. It looks like the DFM itself is not corrupted.
Still having the EClassError issue though. re: It being missing property values, or referencing non-existing properties, etc., a further question: Is the class the error is given for (currently TnxSqlUpdateObject, but probably more waiting in the wings if experience thus far is consistent) usually/always the actual "culprit" class/object?
For instance, right now my main form has four references to TnxSqlUpdateObject, w/those actually dropped on the form. If I put RegisterClass(TnxSqlUpdateObject) in the initialization section, it runs fine for that EClassNotFound error but then goes on to the next one (in this case, TStringField).
I have reinstalled the NexusDB components in this case, and also built a new project using some of the components I thought might be the problem. It compiles and runs fine, UNTIL I add this other form from my real project (which, in turn, unfortunately references quite a few others).
SO, it sounds like my real issue is how to methodically diagnose and fix any and all EClassNotFound errors?
原文:https://stackoverflow.com/questions/483022
最满意答案
首先让我们看看Integer#month ,它返回一个
ActiveSupport::Duration
的实例。 在导轨控制台上:~/rails/rfinan (1296000):1 > elapsed = 1.month => 2592000 ~/rails/rfinan (1296000):1 > elapsed.value => 2592000 ~/rails/rfinan (1296000):1 > elapsed.parts => [[:months,1]] ~/rails/rfinan (1296000):1 > elapsed.is_a? ActiveSupport::Duration => true
该方法的时间: ActiveSupport :: Duration#+
~/rails/rfinan (1296000):1 > sum1 = 1.month + 15.days => 3888000 ~/rails/rfinan (1296000):1 > sum2 = 15.days + 1.month => 3888000 ~/rails/rfinan (1296000):1 > sum1.value => 3888000 ~/rails/rfinan (1296000):1 > sum1.parts => [[:months,1],[:days,15]] ~/rails/rfinan (1296000):1 > sum2.value => 3888000 ~/rails/rfinan (1296000):1 > sum2.parts => [[:days,15],[:months,1]] ~/rails/rfinan (1296000):1 > sum1 == sum2 => true ~/rails/rfinan (1296000):1 > sum1.value == sum2.value => true ~/rails/rfinan (1296000):1 > sum1.parts == sum2.parts => false
现在是日期#+ ,即ActiveSupport版本。
def plus_with_duration(other) #:nodoc: if ActiveSupport::Duration === other other.since(self) else plus_without_duration(other) end end alias_method :plus_without_duration, :+ alias_method :+, :plus_with_duration
这意味着:如果我发送:+到具有ActiveSupport :: Duration实例的Date实例作为参数,它将自动调用ActiveSupport :: Duration# ,并且最后一个调用ActiveSupport :: Duration#sum ,该实例注入日期实例,并在持续时间实例的每个部分上调用Date#advance :
def sum(sign, time = ::Time.current) #:nodoc: parts.inject(time) do |t,(type,number)| if t.acts_like?(:time) || t.acts_like?(:date) if type == :seconds t.since(sign * number) else t.advance(type => sign * number) end else raise ::ArgumentError, "expected a time or date, got #{time.inspect}" end end end
Remmember sum1.parts!= sum2.parts?,总计有条件地向日期实例发送预付款。 让看看什么意思日期#提前
def advance(options) options = options.dup d = self d = d >> options.delete(:years) * 12 if options[:years] d = d >> options.delete(:months) if options[:months] d = d + options.delete(:weeks) * 7 if options[:weeks] d = d + options.delete(:days) if options[:days] d end
当提前recive
month: 1
它会从stdlib中调用Date#>> ,该工作与ActiveSupport :: Duration#+不同。 在irb:~ (main) > Date.new(2014,10,31) >> 1 => #<Date: 2014-11-30 ((2456992j,0s,0n),+0s,2299161j)> ~ (main) > Date.new(2014,10,31) >> 2 => #<Date: 2014-12-31 ((2457023j,0s,0n),+0s,2299161j)> ~ (main) > Date.new(2014,10,31) >> 3 => #<Date: 2015-01-31 ((2457054j,0s,0n),+0s,2299161j)> ~ (main) > Date.new(2014,10,31) >> 4 => #<Date: 2015-02-28 ((2457082j,0s,0n),+0s,2299161j)> ~ (main) > Date.new(2014,10,31) >> 5 => #<Date: 2015-03-31 ((2457113j,0s,0n),+0s,2299161j)> ~ (main) > Date.new(2014,10,31) >> 12 => #<Date: 2015-10-31 ((2457327j,0s,0n),+0s,2299161j)> ~ (main) > Date.new(2014,10,31) >> 1200 =&t; #<Date: 2114-10-31 ((2493486j,0s,0n),+0s,2299161j)> ~ (main) > Date.new(2014,10,31) >> 12000 => #<Date: 3014-10-31 ((2822204j,0s,0n),+0s,2299161j)>
很明显,日期#>>不添加日期,添加月份并保留日期编号。 如果该日期对目标月份无效,则修复该日期。 添加固定的月数不会修复添加的天数,因为取决于开始日期。
现在我们可以说Date#和ActiveSupport :: Duration#+不一样了,我们知道原因。
使用ActiveSupport :: Duration实例(例如持续时间)调用的日期#+不关心duration.value,它使用duration.parts,它们在每种情况下都不相同。
First let see Integer#month, it returns an instance of
ActiveSupport::Duration
. At the rails console:~/rails/rfinan (1296000):1 > elapsed = 1.month => 2592000 ~/rails/rfinan (1296000):1 > elapsed.value => 2592000 ~/rails/rfinan (1296000):1 > elapsed.parts => [[:months,1]] ~/rails/rfinan (1296000):1 > elapsed.is_a? ActiveSupport::Duration => true
It's time for the method: ActiveSupport::Duration#+
~/rails/rfinan (1296000):1 > sum1 = 1.month + 15.days => 3888000 ~/rails/rfinan (1296000):1 > sum2 = 15.days + 1.month => 3888000 ~/rails/rfinan (1296000):1 > sum1.value => 3888000 ~/rails/rfinan (1296000):1 > sum1.parts => [[:months,1],[:days,15]] ~/rails/rfinan (1296000):1 > sum2.value => 3888000 ~/rails/rfinan (1296000):1 > sum2.parts => [[:days,15],[:months,1]] ~/rails/rfinan (1296000):1 > sum1 == sum2 => true ~/rails/rfinan (1296000):1 > sum1.value == sum2.value => true ~/rails/rfinan (1296000):1 > sum1.parts == sum2.parts => false
Now Date#+, the ActiveSupport version.
def plus_with_duration(other) #:nodoc: if ActiveSupport::Duration === other other.since(self) else plus_without_duration(other) end end alias_method :plus_without_duration, :+ alias_method :+, :plus_with_duration
That means: if I send :+ to a Date instance with a ActiveSupport::Duration instance as parameter, it calls ActiveSupport::Duration#since, and the last one calls ActiveSupport::Duration#sum, that injects over the date instance, and calls Date#advance on each of the parts of duration instance:
def sum(sign, time = ::Time.current) #:nodoc: parts.inject(time) do |t,(type,number)| if t.acts_like?(:time) || t.acts_like?(:date) if type == :seconds t.since(sign * number) else t.advance(type => sign * number) end else raise ::ArgumentError, "expected a time or date, got #{time.inspect}" end end end
Remmember sum1.parts != sum2.parts?, sum send advance to the date instance orderly. Let see what means Date#advance
def advance(options) options = options.dup d = self d = d >> options.delete(:years) * 12 if options[:years] d = d >> options.delete(:months) if options[:months] d = d + options.delete(:weeks) * 7 if options[:weeks] d = d + options.delete(:days) if options[:days] d end
When advance recive
month: 1
it calls Date#>> from stdlib, that work diferently of ActiveSupport::Duration#+. At irb:~ (main) > Date.new(2014,10,31) >> 1 => #<Date: 2014-11-30 ((2456992j,0s,0n),+0s,2299161j)> ~ (main) > Date.new(2014,10,31) >> 2 => #<Date: 2014-12-31 ((2457023j,0s,0n),+0s,2299161j)> ~ (main) > Date.new(2014,10,31) >> 3 => #<Date: 2015-01-31 ((2457054j,0s,0n),+0s,2299161j)> ~ (main) > Date.new(2014,10,31) >> 4 => #<Date: 2015-02-28 ((2457082j,0s,0n),+0s,2299161j)> ~ (main) > Date.new(2014,10,31) >> 5 => #<Date: 2015-03-31 ((2457113j,0s,0n),+0s,2299161j)> ~ (main) > Date.new(2014,10,31) >> 12 => #<Date: 2015-10-31 ((2457327j,0s,0n),+0s,2299161j)> ~ (main) > Date.new(2014,10,31) >> 1200 => #<Date: 2114-10-31 ((2493486j,0s,0n),+0s,2299161j)> ~ (main) > Date.new(2014,10,31) >> 12000 => #<Date: 3014-10-31 ((2822204j,0s,0n),+0s,2299161j)>
It's clear that Date#>> don't add days, add months and keep the day number. if the day isn't valid for the target month, it fixes it. Adding a fix number of months doesn't fixes the number of days added, because depend on the start date.
Now we can say that Date#+ is not the same of ActiveSupport::Duration#+, and we know why.
The anwer is Date#+ called with an ActiveSupport::Duration instance (say duration) doesn't care about duration.value, it uses duration.parts, which are different in each case.
相关问答
更多-
尝试这个: for($i=1; $i<=30; $i++) { echo $days_ago = date('Y-m-d', strtotime('-'.$i.' days',strtotime(date('Y-m-d')))); echo '
'; } Try this: for($i=1; $i<=30; $i++) { echo $days_ago = date('Y-m-d', strtotime('-'.$i.' days',strtotime(date('Y-m ... -
该月份为零为基础的JavaScript。 天和年是一个基础。 去搞清楚。 UPDATE 这是因为JavaScript的创造者所在 JS不得不像Java那样看起来就像是Java的笨孩子哥哥或者是人质人物。 此外,我必须在十天内完成,或者比JS更糟糕的事情。 http://www.jwz.org/blog/2010/10/every-day-i-learn-something-new-and-stupid/#comment-1021 The month is zero-based for JavaScript. ...
-
1.month来自Active Support,而不是Ruby stdlib,因此您需要将此依赖项加载到脚本上下文中。 因此,如果要在整个Rails环境下运行此自定义脚本(加载所有依赖项),则应使用rails runner : runner以非交互方式在Rails的上下文中运行Ruby代码 $ bin/rails runner path_to_your_script.rb 在Rails 2中: script/runner 。 或者,如果您只需要使用Active Support方法,请尝试明确要求它: re ...
-
不是真的。 ActiveSupport::Duration可以在幕后进行一些工作,使日期更直观。 以这个例子: Time.now + 1.month 无论Time.now是哪个月,无论月中的天数如何,结果总是提前1个月。 2月1日到3月1日。3月1日到4月1日。 但是,当您使用电话时,您可以这样做: time = Time.now time - 1.month #=> April 1 time - 3.days #=> March 29 time + 1.month #=> April 29 time + ...
-
您需要做的是解决您的问题,您可以按以下顺序将代码转换回本地时间: simpleDateFormatter.setTimeZone(TimeZone.getDefault()); simpleTimeFormatter.setTimeZone(TimeZone.getDefault()); Date getDate = simpleDateFormatter.parse(utcDate); Date getTime = simpleTimeFormatter.parse(utcTime); 你需要做的是等 ...
-
MySQL WHERE日期> 15天(MySQL WHERE Date > 15 Days)[2022-03-30]
对于DATEDIFF如果第一个项目的日期小于第二个项目,那么它将返回一个负数(因此永远不会大于16)而不是一个正数。 所以翻转它们,你想把后一个日期作为第一个参数: ... WHERE DATEDIFF( CURDATE(), Due_Date ) > 15 For DATEDIFF if the first item is a smaller date than the second item then it returns a negative number (as such could never ... -
首先让我们看看Integer#month ,它返回一个ActiveSupport::Duration的实例。 在导轨控制台上: ~/rails/rfinan (1296000):1 > elapsed = 1.month => 2592000 ~/rails/rfinan (1296000):1 > elapsed.value => 2592000 ~/rails/rfinan (1296000):1 > elapsed.parts => [[:months,1]] ~/rails/rfinan (1296 ...
-
月租功能(rent days in month function)[2023-08-03]
library(lubridate) start_date <- as.Date("2017-06-15") end_date <- as.Date("2018-06-14") current_month<- as.Date("2017-06-01") rent_days_in_month = function(start_date, end_date, current_month){ if(month(current_month) == month(start_date) & year(curren ... -
我认为您可以使用offsets ,请参阅文档 : print (tidx + pd.offsets.Day(15)) DatetimeIndex(['2016-04-15', '2016-05-15'], dtype='datetime64[ns]', freq=None) I think you can use offsets, see docs: print (tidx + pd.offsets.Day(15)) DatetimeIndex(['2016-04-15', '2016-05-15'], ...
-
这应该可以做到这一点: $(function(){ $("input").datepicker( { beforeShowDay: function (date) { if (date.getDate() == 15 || date.getDate() == 1) { return [true, '']; } return [false, '']; } }); }); 查 ...