I know it's nearly Christmas, but at my desk it's Spring(4D) again. I am getting the exception
I know it's nearly Christmas, but at my desk it's Spring(4D) again. I am getting the exception
"Type is missing a guid: Systematic.BaseTypes.DevExp.TFieldFactory."
So what I have (simplified) is below and the call stack at the end
I've checked that all interfaces have GUIDs. Any suggestions greatly appreciated
Interface
Type
IMyField = interface
['{7A54F949-C1C9-474C-B848-3234FBAAB48E}']
{procs and stuff}
end;
TMyFieldBase = class(TInterfacedObject, IMyField)
public
constructor Create(aOwner: TComponent; aGroupName: string);
end;
TMyFieldOne = class(TMyFieldBase)
end;
TMyFieldTwo = class(TMyFieldBase)
end;
Implementation
var MyContainer: TContainer;
Type
{M+}
TFieldFactory = reference to function(AOwner: TComponent;
aGroupName: string): IDevExCustomField;
{$M-}
Initialization
MyContainer := TContainer.Create;
MyContainer.RegisterType('One');
MyContainer.RegisterType('Two');
MyContainer.RegisterFactory.AsFactory('One');
MyContainer.RegisterFactory.AsFactory('Two');
MyContainer.Build;
end.
Here's the MadExcept call stack
main thread ($252c):
00930edb +73 SMXPHM.exe Spring.Container.Registration TComponentRegistry.CheckIsNonGuidInterface
00930f38 +34 SMXPHM.exe Spring.Container.Registration TComponentRegistry.Validate
0093112e +5a SMXPHM.exe Spring.Container.Registration TComponentRegistry.RegisterService
00935972 +32 SMXPHM.exe Spring.Container.Registration TRegistration.Implements
035a36a0 +34 SMXPHM.exe Systematic.BaseTypes.DevExp 842 +0 {Spring.Container.Registration}TRegistration.Implements
035a475b +33 SMXPHM.exe Systematic.BaseTypes.DevExp 2147 +0 {Spring.Container.Registration}TRegistration.Implements
035a4546 +4e SMXPHM.exe Systematic.BaseTypes.DevExp 1575 +0 TContainer.RegisterType
035a4046 +2e SMXPHM.exe Systematic.BaseTypes.DevExp 1719 +0 TContainer.RegisterFactory
0364753c +c8 SMXPHM.exe Systematic.BaseTypes.DevExp 468 +12 initialization
"Type is missing a guid: Systematic.BaseTypes.DevExp.TFieldFactory."
So what I have (simplified) is below and the call stack at the end
I've checked that all interfaces have GUIDs. Any suggestions greatly appreciated
Interface
Type
IMyField = interface
['{7A54F949-C1C9-474C-B848-3234FBAAB48E}']
{procs and stuff}
end;
TMyFieldBase = class(TInterfacedObject, IMyField)
public
constructor Create(aOwner: TComponent; aGroupName: string);
end;
TMyFieldOne = class(TMyFieldBase)
end;
TMyFieldTwo = class(TMyFieldBase)
end;
Implementation
var MyContainer: TContainer;
Type
{M+}
TFieldFactory = reference to function(AOwner: TComponent;
aGroupName: string): IDevExCustomField;
{$M-}
Initialization
MyContainer := TContainer.Create;
MyContainer.RegisterType
MyContainer.RegisterType
MyContainer.RegisterFactory
MyContainer.RegisterFactory
MyContainer.Build;
end.
Here's the MadExcept call stack
main thread ($252c):
00930edb +73 SMXPHM.exe Spring.Container.Registration TComponentRegistry.CheckIsNonGuidInterface
00930f38 +34 SMXPHM.exe Spring.Container.Registration TComponentRegistry.Validate
0093112e +5a SMXPHM.exe Spring.Container.Registration TComponentRegistry.RegisterService
00935972 +32 SMXPHM.exe Spring.Container.Registration TRegistration.Implements
035a36a0 +34 SMXPHM.exe Systematic.BaseTypes.DevExp 842 +0 {Spring.Container.Registration}TRegistration
035a475b +33 SMXPHM.exe Systematic.BaseTypes.DevExp 2147 +0 {Spring.Container.Registration}TRegistration
035a4546 +4e SMXPHM.exe Systematic.BaseTypes.DevExp 1575 +0 TContainer.RegisterType
035a4046 +2e SMXPHM.exe Systematic.BaseTypes.DevExp 1719 +0 TContainer.RegisterFactory
0364753c +c8 SMXPHM.exe Systematic.BaseTypes.DevExp 468 +12 initialization
1. There is a missing $ on the M+
ReplyDelete2. After fixing that you will get an ERegistrationException with message 'Duplicate service name found'. (see https://bitbucket.org/sglienke/spring4d/issues/58)
3. Don't call AsFactory but directly pass servicename (for the factory itself) and the resolvedServiceName to the RegisterFactory call (FWIW AsFactory will be removed in a future version to clean up the registration API a bit).
Wood and trees, many thanks Stefan Glienke a star as usual
ReplyDelete