Strange behaviour in Delphi XE2

Hi

I’m testing implementation of LexActivator in an existing product in Delphi XE2. If I run the application with all the LexActivator code commented out, but with LexActivator.pas is still in the main “uses” cleause, then I get an Error 43 (the product id is incorrect) when the application closes. I have double-checked, and I am certain that no code related to LexActivator was compiled in - it’s just listed in the uses clause but is never actually used.

I tried to test this in a new empty project as well. If I create a totally new (empty) project in Delphi XE2 and run the project, it comes up with the empty main form (as it should). If I then add LexActivator.pas to the “uses” clause and run it again, nothing happens. The application doesn’t start, and the main form is never shown. If I remove LexActivator.pas from the uses clause again, everything works fine.

Any idea what’s going on?

Hi,

I am not sure why this is happening. Here are some potential causes and suggestions to troubleshoot the problem:

  1. Initialization and Finalization in LexActivator.pas: Delphi units can have initialization and finalization sections that are executed when the application starts and ends, regardless of whether the rest of the unit’s code is used. If LexActivator.pas has these sections, they might be trying to initialize or finalize the LexActivator library, leading to the Error 43 when the application closes.

  2. Automatic Calls to Initialization/Finalization Routines: Delphi automatically calls the initialization and finalization routines of all units listed in the uses clause, even if their functions or procedures are not explicitly called in the code. This automatic mechanism could be triggering the issue.