0

I encountered some error for which i just can't find a proper hint on the net. Hopefully one of you can point me to the right direction.

Simple Problem: I've got a class inheriting from TObject. I've got a constructor named Create and i want to call Inherited on the very first line of the very only constructor. Does not work!

On compile i get a

[dcc32 Fehler] ULSRAware.pas(58): E2008 Inkompatible Typen

If I comment the inherited out it compiles fine but on runtime on creating the object, while I can access methods regulary (like some private _InitAdo method), every access to a property yields an access violation error.

I guess it's coming from calling the inherited nonetheless but without any sufficient success.

This is the declaration at the head of the Unit. Just to mention it, it's just this class in the unit. And of course in the implementation section the implementation.

type TLAConnect = class( TObject )

  private
    _mailHost : String;
    _mailPort : Integer;
    _mailUsername : String;
    _mailPassword : String;
    _mailAddress : String;

    _sql_script_sms : String;
    _sql_script_mail: String;
    _sms_mail_addon : String;

    //connection : TADOConnection;
    (*
    procedure SendMessage( recp:String; subj, body : String );
    procedure _InitAdo( config_filename : String; path: String );
    function GetMsgId( msg : String ) : Integer;

    function GetMsgIdFromByteBit( byte, bit : String ) : Integer;
    function ProcessMessage( msgId : Integer ): String;

    procedure Trigger( msgId : Integer );
    procedure QuittMsg( msgId : Integer );
    procedure MakeMessage( _msgid : Integer; _fsms, _fmail : Boolean; _smsgl, _smsgs : String );
    function CreateNewByteTrigger( byte, bit : String ) : Integer;   
  *)
  public
    Constructor Create( config : String );
    Destructor Destroy; override;

    //function Call( msg:String ) : Boolean;

  end;

And the implementation of the constructor and the desctructor.

Constructor TLAConnect.Create( config : String );
begin
  inherited.Create;
  //self._InitAdo( config, 'lsraware ado' );

  _mailHost      := 'blabla';
  _mailPort      := 587;
  _mailUsername  := 'blabla_user';
  _mailPassword  := 'blabla_pass';

  _mailAddress   := 'blabal';
end;

Destructor TLAConnect.Destroy;
begin
  self.connection.Free;
  Inherited;
end;
kaymcray
  • 19
  • 5
  • 1
    Call `inherited Create;` in your constructor, not just `inherited`, as just this standalone call passes the parameters to the matching method prototype (which does not exist in your case). And better `reintroduce` your `constructor`. – Victoria Jun 26 '18 at 16:27
  • Thanks Victoria! While your suggestion fixed the problem with the E2008 now it crashes like the way it does without the inherited. Any idea why this simple constructor does not like to access it's members? Even without the _InitAdo or anything else it crashes on the first writing attempt... I'm pretty confused! – kaymcray Jun 26 '18 at 16:29
  • 4
    Have no idea, sorry. Maybe you missed to create `connection` object? Hard to say. Debug your code. That will answer your question ;-) – Victoria Jun 26 '18 at 16:30
  • It's impossible to explain your new error, because you didn't post any code related to it. We can't solve problems with code we can't see. – Ken White Jun 26 '18 at 23:42
  • @KenWhite That is what i wanted to point out with "Even witout the _InitAdo or anything else..." I commented out all the methods leaving only the member Strings and Integers defined in the header. So the remaining code - which crashes - is the stuff i posted. Nothing else. It's all commented out. Still crashing. The debugger says the self is not accessible. I edited the code accordingly to show what i mean! – kaymcray Jun 27 '18 at 08:35
  • I found it. God damnit! Such a stupid ****. Thanks a lot to both of you! I just called the Constructor the wrong way - that's so embarassing! – kaymcray Jun 27 '18 at 08:48
  • Can you show how you create the instance of TLAConnect? You might have typed VariableName.Create instead of calling the constructor with the type. Edit: Nevermind, saw your comment. – nil Jun 27 '18 at 08:49

0 Answers0