Board index » delphi » "Catastrophic Failure" w/ TIdWhoIs

"Catastrophic Failure" w/ TIdWhoIs

Hello all:

I am attempting to write an in-process COM program for use in an ASP page
that will gather specific WhoIs information on a domain by use of the
TIdWhoIs (Indy WhoIs Client) component.  My code works great as a
stand-alone application, however, when I copy the code into a function of an
automation object, it fails returning 'Catastrophic Failure'.  I've figured
out that I get the error as soon as I try to use the TIdWhoIs component.
What could be wrong?  For my USES I have IdBaseComponent, IdComponent,
IdTCPConnection, IdTCPClient and IdWhois.  I am also declaring   IdWhois1:
TIdWhois; under my type.

Here's a snippet...

-------------------------------------------------------------------------

unit Unit1;

{$WARN SYMBOL_PLATFORM OFF}

interface

uses
  ComObj, ActiveX, UMIWhoIsDLL_TLB, StdVcl, IdBaseComponent, IdComponent,
IdTCPConnection,
  IdTCPClient, IdWhois, Classes, SysUtils;

type
  TCoWhoIs = class(TAutoObject, ICoWhoIs)
  IdWhois1: TIdWhois;
  protected
    procedure whois(domain: OleVariant); safecall;
    function Get_info: OleVariant; safecall;
    { Protected declarations }
  end;

implementation

uses ComServ;
var
        strDomain: String;
        list: TStringList;
        whoisSvr: String;

procedure TCoWhoIs.whois(domain: OleVariant);
begin
        strDomain:=domain;
end;

function TCoWhoIs.Get_info: OleVariant;
var
        i, x: Integer;
begin
        list := TStringList.Create;

//        idwhois1.Host:='whois.internic.net';    <-------------This is
where is fails.
//        list.text := idwhois1.whois('=' + strDomain);
//        idwhois1.disconnect;

-------------------------------------------------------------------------

Thank you very much for your time,

Aaron

 

Re:"Catastrophic Failure" w/ TIdWhoIs


  I don't see where you ever create an instance of idwhois1.  If you don't
create it, it will be nil when you try to access it, and will give you a
catastrophic failure error.  If in your test app you dropped an instance of
this TIdWhoIs class on your form, then the form auto-created it for you.  In
a unit that isnot a form, you need to create it before you can use it, and
free it when you are done.  A good place to do that in a COM object is in
overriden Initialize and Destroy methods.
-Howard

Other Threads