Constructors are excluded in EXE

64 views
Skip to first unread message

Mobile Lin

unread,
Oct 15, 2024, 6:55:10 AM10/15/24
to Spring4D
It seems a lot of constructors in my application suddenly disappeared from the EXE thus the container can never resolve the services which have these constructors.

Does Delphi auto exclude unused code (in my case, there is no code call these constructors directly)? If it does, how does Spring4D overcome this? 

Stefan Glienke

unread,
Oct 15, 2024, 6:56:29 AM10/15/24
to Spring4D
Assuming that you added those classes to the container via Registration API it could be that you have specified $WEAKLINKRTTI ON somewhere - see https://docwiki.embarcadero.com/RADStudio/Athens/en/WEAKLINKRTTI_directive_(Delphi)

Mobile Lin

unread,
Oct 16, 2024, 3:27:59 AM10/16/24
to Spring4D
Thanks for quick response. I have had a search on all my repos, couldn't find it anywhere.

I have also tried {$STRONGLINKTYPES ON} in the .drp file like:

. program MyApp;
 {$WEAKLINKRTTI OFF}
 {$STRONGLINKTYPES ON}
 {$R 'VersionInfo.res' 'VersionInfo.rc'}

uses
...

Btw, I am using Delphi XE5, and the app is a mixture of VCL and FMX.

Mobile Lin

unread,
Nov 15, 2024, 2:20:38 AM11/15/24
to Spring4D
It turned out that Nullable<T> came from  delphi-neon/Source/Neon.Core.Nullables.pas at master · paolo-rossi/delphi-neon can cause Spring4D DI failed to resolve some classes event they are not using Nullable<T> at all, and it only happened if Nullables.pas and my units were compiled and linked at one go, if later I made changes to my units and do a make, it may worked again if only my units were recompiled during the build. So it has some differences between compiling all units in one build or not.
Reply all
Reply to author
Forward
0 new messages