0

I have a Delphi program which runs on Microsoft Windows (English) environment, but fails when running in a Windows (Chinese) environment.

The error message is:

Exception EReadError in module rtl160.bpl.
Error reading Button2.Click Invalid property Value

However, the "Button2" has a valid OnClick event method.

I have several other similar Delphi programs which run in both environments. I haven't spotted what is different about this particular program.

Anyone else run into this sort of thing? Where are the best areas to look?

Mike Pettigrew
  • 156
  • 1
  • 8
  • Start by looking at the .dfm file extracted from the executable. Make a [mcve]. – David Heffernan Oct 06 '15 at 19:19
  • Thank you for your response. The DFM appears to show a properly formatted object "button2: TButton" with an "OnClick" method which references a valid name in the body of the code. – Mike Pettigrew Oct 06 '15 at 19:26
  • I guess you need to do some debugging then – David Heffernan Oct 06 '15 at 19:29
  • Been debugging this thing for several days now. "ShowMessage" calls planted at various points appear to indicate that the program is never even loading. Meanwhile, its' cousins are running just fine.... – Mike Pettigrew Oct 06 '15 at 19:32
  • Indeed, it's failing to stream in the DFM. Do you have access to the RTL? – Jerry Dodge Oct 06 '15 at 19:54
  • In my copy of Delphi, the "Invalid property value" message comes from the `SInvalidPropertyValue` identifier, which is used exactly once. Set a breakpoint there, and then use the call stack and further breakpoints to figure out how you get there. (The "Error reading Button2.Click" message comes from `SPropertyException`, which is also used only once, but it's a more generic message that isn't very helpful.) – Rob Kennedy Oct 06 '15 at 20:27
  • Please show the actual DFM. There is no `Button2.Click` property. Are you sure that is what the error actually says? It should be saying `Button2.OnClick` instead. Make sure the DFM is not corrupted, and that you are reading/quoting the error message correctly. That being said, the DFM streaming can raise that error when streaming an event handler if the specified named method is not found in the Button's root `Form` object (ie, the Form's `MethodAddress()` method returns a nil pointer). Make sure you are compiling with RTTI enabled, for instance. – Remy Lebeau Oct 06 '15 at 20:51
  • If needed, one thing you could try is to invoke DFM streaming manually so you can assign handlers to the `TReader.OnFindMethod` and `TReader.OnFindMethodInstance` events, then they will tell you the method name being looked for, and whether the DFM was able to find it before calling `OnFindMethod/Instance`. – Remy Lebeau Oct 06 '15 at 20:55
  • It seems that the problem is with the Language Translator utility. Most of the forms are created at load-time and if any of their controls have been deleted or changed, the program crashes with one of the "Invalid property value" messages. The "Refresh Language Files" option of the Translator system does not seem to correct the problem. I am in further communication with the vendor for a solution. – Mike Pettigrew Oct 08 '15 at 01:22
  • The Language Translator inserts an initialization call in the FormShow method of the startup form. In this particular application, the startup form may hide while showing a child form then show itself when the child form exits. The subsequent FormShow action calls the Language Translator initialization method again. The error message is spurious as the real problem is caused by calling initialization twice. The fix was to set a persistent flag in the FormShow method so it would not initialize the form again. – Mike Pettigrew Oct 09 '15 at 16:23

0 Answers0