Link to home
Start Free TrialLog in
Avatar of IT79637
IT79637Flag for United States of America

asked on

How to fix Delphi 7 "RCP Server is Unavailable" error?

Hi Experts,

I've written a Client program to test the methods of a automation server.  Both programs are written in Delphi 7.  I'm on a WinXP Pro, SP3 box.

When I click the "Launch Srever" button, I get the following error: "Client1.exe raised exception class EOleSysError with message 'The RPC server is unavailable'."

The Windows RPC service is running. What have I missed?  

The code for the Client (calling) program and import library (TLB) for the automation server is in the Code section below.  Line 76 is the Create method in client1 program.

Thanks much.

CLIENT PROGRAM
==============
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ImageDisplay_TLB, StdCtrls  ;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Edit6: TEdit;
    Edit7: TEdit;
    Edit8: TEdit;
    Edit9: TEdit;
    Edit10: TEdit;
    Edit11: TEdit;
    Edit12: TEdit;
    Edit13: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    Label14: TLabel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Button5: TButton;
    Button6: TButton;
    Button7: TButton;
    Button8: TButton;
    Button9: TButton;


    procedure Button7Click(Sender: TObject);
    procedure Button8Click(Sender: TObject);
    procedure Button9Click(Sender: TObject);
  private
    { Private declarations }
    IntfObj : IImageDisplayInterface;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button7Click(Sender: TObject);
begin
  Close;
end;

procedure TForm1.Button8Click(Sender: TObject);
begin
  IntfObj := CoImageDisplayInterface.Create;
end;

procedure TForm1.Button9Click(Sender: TObject);
begin
  IntfObj := Nil;
end;

end.

IMPORT LIBRARY
==============

unit ImageDisplay_TLB;

// ************************************************************************ //
// WARNING                                                                    
// -------                                                                    
// The types declared in this file were generated from data read from a       
// Type Library. If this type library is explicitly or indirectly (via        
// another type library referring to this type library) re-imported, or the   
// 'Refresh' command of the Type Library Editor activated while editing the   
// Type Library, the contents of this file will be regenerated and all        
// manual modifications will be lost.                                         
// ************************************************************************ //

// PASTLWTR : 1.2
// File generated on 12/30/2009 7:43:14 PM from Type Library described below.

// ************************************************************************  //
// Type Lib: C:\Program Files\Borland\Delphi7\Projects\Display5\ImageDisplay.exe (1)
// LIBID: {AAEA8E84-C478-4E45-B02F-1E3FBB4F53AA}
// LCID: 0
// Helpfile: 
// HelpString: ImageDisplay Library
// DepndLst: 
//   (1) v2.0 stdole, (C:\WINDOWS\system32\stdole2.tlb)
// ************************************************************************ //
// *************************************************************************//
// NOTE:                                                                      
// Items guarded by $IFDEF_LIVE_SERVER_AT_DESIGN_TIME are used by properties  
// which return objects that may need to be explicitly created via a function 
// call prior to any access via the property. These items have been disabled  
// in order to prevent accidental use from within the object inspector. You   
// may enable them by defining LIVE_SERVER_AT_DESIGN_TIME or by selectively   
// removing them from the $IFDEF blocks. However, such items must still be    
// programmatically created via a method of the appropriate CoClass before    
// they can be used.                                                          
{$TYPEDADDRESS OFF} // Unit must be compiled without type-checked pointers. 
{$WARN SYMBOL_PLATFORM OFF}
{$WRITEABLECONST ON}
{$VARPROPSETTER ON}
interface

uses Windows, ActiveX, Classes, Graphics, OleServer, StdVCL, Variants;
  

// *********************************************************************//
// GUIDS declared in the TypeLibrary. Following prefixes are used:        
//   Type Libraries     : LIBID_xxxx                                      
//   CoClasses          : CLASS_xxxx                                      
//   DISPInterfaces     : DIID_xxxx                                       
//   Non-DISP interfaces: IID_xxxx                                        
// *********************************************************************//
const
  // TypeLibrary Major and minor versions
  ImageDisplayMajorVersion = 1;
  ImageDisplayMinorVersion = 0;

  LIBID_ImageDisplay: TGUID = '{AAEA8E84-C478-4E45-B02F-1E3FBB4F53AA}';

  IID_IImageDisplayInterface: TGUID = '{4A4F1922-BAD7-4E7E-A184-1B0F4A92A312}';
  DIID_IImageDisplayInterfaceEvents: TGUID = '{37D41944-A35F-4747-A90A-315522F44D89}';
  CLASS_ImageDisplayInterface: TGUID = '{1DEFFA6A-4CE4-4583-AD8C-20EC90539368}';
type

// *********************************************************************//
// Forward declaration of types defined in TypeLibrary                    
// *********************************************************************//
  IImageDisplayInterface = interface;
  IImageDisplayInterfaceDisp = dispinterface;
  IImageDisplayInterfaceEvents = dispinterface;

// *********************************************************************//
// Declaration of CoClasses defined in Type Library                       
// (NOTE: Here we map each CoClass to its Default Interface)              
// *********************************************************************//
  ImageDisplayInterface = IImageDisplayInterface;


// *********************************************************************//
// Interface: IImageDisplayInterface
// Flags:     (4416) Dual OleAutomation Dispatchable
// GUID:      {4A4F1922-BAD7-4E7E-A184-1B0F4A92A312}
// *********************************************************************//
  IImageDisplayInterface = interface(IDispatch)
    ['{4A4F1922-BAD7-4E7E-A184-1B0F4A92A312}']
    function WorkInvoice(Company: OleVariant; InvType: OleVariant; OperatorID: OleVariant; 
                         out DocID: OleVariant; out DocSeqCount: OleVariant; 
                         out MethodStatus: OleVariant): OleVariant; safecall;
    function GetVndrNameAddr(SrchStr: OleVariant; var VndrCount: OleVariant; 
                             out VndrNameAddr: OleVariant; out MethodStatus: OleVariant): OleVariant; safecall;
    function SaveVoucher(DocID: OleVariant; DocIDSeq: OleVariant; VndrNo: OleVariant; 
                         InvNo: OleVariant; InvDate: OleVariant; VchrID: OleVariant; 
                         PONum: OleVariant; Contract: OleVariant; OperatorID: OleVariant; 
                         out MethodStatus: OleVariant): OleVariant; safecall;
    function UnBusyInvoice(DocID: OleVariant; OperatorID: OleVariant; out MethodStatus: OleVariant): OleVariant; safecall;
    procedure DisplayMessage(message1: OleVariant); safecall;
  end;

// *********************************************************************//
// DispIntf:  IImageDisplayInterfaceDisp
// Flags:     (4416) Dual OleAutomation Dispatchable
// GUID:      {4A4F1922-BAD7-4E7E-A184-1B0F4A92A312}
// *********************************************************************//
  IImageDisplayInterfaceDisp = dispinterface
    ['{4A4F1922-BAD7-4E7E-A184-1B0F4A92A312}']
    function WorkInvoice(Company: OleVariant; InvType: OleVariant; OperatorID: OleVariant; 
                         out DocID: OleVariant; out DocSeqCount: OleVariant; 
                         out MethodStatus: OleVariant): OleVariant; dispid 201;
    function GetVndrNameAddr(SrchStr: OleVariant; var VndrCount: OleVariant; 
                             out VndrNameAddr: OleVariant; out MethodStatus: OleVariant): OleVariant; dispid 202;
    function SaveVoucher(DocID: OleVariant; DocIDSeq: OleVariant; VndrNo: OleVariant; 
                         InvNo: OleVariant; InvDate: OleVariant; VchrID: OleVariant; 
                         PONum: OleVariant; Contract: OleVariant; OperatorID: OleVariant; 
                         out MethodStatus: OleVariant): OleVariant; dispid 203;
    function UnBusyInvoice(DocID: OleVariant; OperatorID: OleVariant; out MethodStatus: OleVariant): OleVariant; dispid 204;
    procedure DisplayMessage(message1: OleVariant); dispid 205;
  end;

// *********************************************************************//
// DispIntf:  IImageDisplayInterfaceEvents
// Flags:     (4096) Dispatchable
// GUID:      {37D41944-A35F-4747-A90A-315522F44D89}
// *********************************************************************//
  IImageDisplayInterfaceEvents = dispinterface
    ['{37D41944-A35F-4747-A90A-315522F44D89}']
  end;

// *********************************************************************//
// The Class CoImageDisplayInterface provides a Create and CreateRemote method to          
// create instances of the default interface IImageDisplayInterface exposed by              
// the CoClass ImageDisplayInterface. The functions are intended to be used by             
// clients wishing to automate the CoClass objects exposed by the         
// server of this typelibrary.                                            
// *********************************************************************//
  CoImageDisplayInterface = class
    class function Create: IImageDisplayInterface;
    class function CreateRemote(const MachineName: string): IImageDisplayInterface;
  end;


// *********************************************************************//
// OLE Server Proxy class declaration
// Server Object    : TImageDisplayInterface
// Help String      : ImageDisplayInterface Object
// Default Interface: IImageDisplayInterface
// Def. Intf. DISP? : No
// Event   Interface: IImageDisplayInterfaceEvents
// TypeFlags        : (2) CanCreate
// *********************************************************************//
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  TImageDisplayInterfaceProperties= class;
{$ENDIF}
  TImageDisplayInterface = class(TOleServer)
  private
    FIntf:        IImageDisplayInterface;
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
    FProps:       TImageDisplayInterfaceProperties;
    function      GetServerProperties: TImageDisplayInterfaceProperties;
{$ENDIF}
    function      GetDefaultInterface: IImageDisplayInterface;
  protected
    procedure InitServerData; override;
    procedure InvokeEvent(DispID: TDispID; var Params: TVariantArray); override;
  public
    constructor Create(AOwner: TComponent); override;
    destructor  Destroy; override;
    procedure Connect; override;
    procedure ConnectTo(svrIntf: IImageDisplayInterface);
    procedure Disconnect; override;
    function WorkInvoice(Company: OleVariant; InvType: OleVariant; OperatorID: OleVariant; 
                         out DocID: OleVariant; out DocSeqCount: OleVariant; 
                         out MethodStatus: OleVariant): OleVariant;
    function GetVndrNameAddr(SrchStr: OleVariant; var VndrCount: OleVariant; 
                             out VndrNameAddr: OleVariant; out MethodStatus: OleVariant): OleVariant;
    function SaveVoucher(DocID: OleVariant; DocIDSeq: OleVariant; VndrNo: OleVariant; 
                         InvNo: OleVariant; InvDate: OleVariant; VchrID: OleVariant; 
                         PONum: OleVariant; Contract: OleVariant; OperatorID: OleVariant; 
                         out MethodStatus: OleVariant): OleVariant;
    function UnBusyInvoice(DocID: OleVariant; OperatorID: OleVariant; out MethodStatus: OleVariant): OleVariant;
    procedure DisplayMessage(message1: OleVariant);
    property DefaultInterface: IImageDisplayInterface read GetDefaultInterface;
  published
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
    property Server: TImageDisplayInterfaceProperties read GetServerProperties;
{$ENDIF}
  end;

{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
// *********************************************************************//
// OLE Server Properties Proxy Class
// Server Object    : TImageDisplayInterface
// (This object is used by the IDE's Property Inspector to allow editing
//  of the properties of this server)
// *********************************************************************//
 TImageDisplayInterfaceProperties = class(TPersistent)
  private
    FServer:    TImageDisplayInterface;
    function    GetDefaultInterface: IImageDisplayInterface;
    constructor Create(AServer: TImageDisplayInterface);
  protected
  public
    property DefaultInterface: IImageDisplayInterface read GetDefaultInterface;
  published
  end;
{$ENDIF}


procedure Register;

resourcestring
  dtlServerPage = 'ActiveX';

  dtlOcxPage = 'ActiveX';

implementation

uses ComObj;

class function CoImageDisplayInterface.Create: IImageDisplayInterface;
begin
  Result := CreateComObject(CLASS_ImageDisplayInterface) as IImageDisplayInterface;
end;

class function CoImageDisplayInterface.CreateRemote(const MachineName: string): IImageDisplayInterface;
begin
  Result := CreateRemoteComObject(MachineName, CLASS_ImageDisplayInterface) as IImageDisplayInterface;
end;

procedure TImageDisplayInterface.InitServerData;
const
  CServerData: TServerData = (
    ClassID:   '{1DEFFA6A-4CE4-4583-AD8C-20EC90539368}';
    IntfIID:   '{4A4F1922-BAD7-4E7E-A184-1B0F4A92A312}';
    EventIID:  '{37D41944-A35F-4747-A90A-315522F44D89}';
    LicenseKey: nil;
    Version: 500);
begin
  ServerData := @CServerData;
end;

procedure TImageDisplayInterface.Connect;
var
  punk: IUnknown;
begin
  if FIntf = nil then
  begin
    punk := GetServer;
    ConnectEvents(punk);
    Fintf:= punk as IImageDisplayInterface;
  end;
end;

procedure TImageDisplayInterface.ConnectTo(svrIntf: IImageDisplayInterface);
begin
  Disconnect;
  FIntf := svrIntf;
  ConnectEvents(FIntf);
end;

procedure TImageDisplayInterface.DisConnect;
begin
  if Fintf <> nil then
  begin
    DisconnectEvents(FIntf);
    FIntf := nil;
  end;
end;

function TImageDisplayInterface.GetDefaultInterface: IImageDisplayInterface;
begin
  if FIntf = nil then
    Connect;
  Assert(FIntf <> nil, 'DefaultInterface is NULL. Component is not connected to Server. You must call ''Connect'' or ''ConnectTo'' before this operation');
  Result := FIntf;
end;

constructor TImageDisplayInterface.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  FProps := TImageDisplayInterfaceProperties.Create(Self);
{$ENDIF}
end;

destructor TImageDisplayInterface.Destroy;
begin
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  FProps.Free;
{$ENDIF}
  inherited Destroy;
end;

{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
function TImageDisplayInterface.GetServerProperties: TImageDisplayInterfaceProperties;
begin
  Result := FProps;
end;
{$ENDIF}

procedure TImageDisplayInterface.InvokeEvent(DispID: TDispID; var Params: TVariantArray);
begin
  case DispID of
    -1: Exit;  // DISPID_UNKNOWN
  end; {case DispID}
end;

function TImageDisplayInterface.WorkInvoice(Company: OleVariant; InvType: OleVariant; 
                                            OperatorID: OleVariant; out DocID: OleVariant; 
                                            out DocSeqCount: OleVariant; 
                                            out MethodStatus: OleVariant): OleVariant;
begin
  Result := DefaultInterface.WorkInvoice(Company, InvType, OperatorID, DocID, DocSeqCount, 
                                         MethodStatus);
end;

function TImageDisplayInterface.GetVndrNameAddr(SrchStr: OleVariant; var VndrCount: OleVariant; 
                                                out VndrNameAddr: OleVariant; 
                                                out MethodStatus: OleVariant): OleVariant;
begin
  Result := DefaultInterface.GetVndrNameAddr(SrchStr, VndrCount, VndrNameAddr, MethodStatus);
end;

function TImageDisplayInterface.SaveVoucher(DocID: OleVariant; DocIDSeq: OleVariant; 
                                            VndrNo: OleVariant; InvNo: OleVariant; 
                                            InvDate: OleVariant; VchrID: OleVariant; 
                                            PONum: OleVariant; Contract: OleVariant; 
                                            OperatorID: OleVariant; out MethodStatus: OleVariant): OleVariant;
begin
  Result := DefaultInterface.SaveVoucher(DocID, DocIDSeq, VndrNo, InvNo, InvDate, VchrID, PONum, 
                                         Contract, OperatorID, MethodStatus);
end;

function TImageDisplayInterface.UnBusyInvoice(DocID: OleVariant; OperatorID: OleVariant; 
                                              out MethodStatus: OleVariant): OleVariant;
begin
  Result := DefaultInterface.UnBusyInvoice(DocID, OperatorID, MethodStatus);
end;

procedure TImageDisplayInterface.DisplayMessage(message1: OleVariant);
begin
  DefaultInterface.DisplayMessage(message1);
end;

{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
constructor TImageDisplayInterfaceProperties.Create(AServer: TImageDisplayInterface);
begin
  inherited Create;
  FServer := AServer;
end;

function TImageDisplayInterfaceProperties.GetDefaultInterface: IImageDisplayInterface;
begin
  Result := FServer.DefaultInterface;
end;

{$ENDIF}

procedure Register;
begin
  RegisterComponents(dtlServerPage, [TImageDisplayInterface]);
end;

end.

Open in new window

Avatar of IT79637
IT79637
Flag of United States of America image

ASKER

I went into services and started "DOM Server Process Launcher".  

Now the error is: "Client1.exe raised exception class EIntfCast Error with message 'Interface not supported.'"  Could it be that I am using the CoImageDisplayInterface  (line 221)in the class section of the TBL file?
Avatar of IT79637

ASKER

By the way the server is launched. Processing fails on the Create method.
ASKER CERTIFIED SOLUTION
Avatar of IT79637
IT79637
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial