我用Midas做的一个三层架构的程序.中间层和客户端都连好了.我在应用服务器上定义了这样一个过程:...
public
    { Public declarations }
    procedure aa;
end;...procedure TMyServer.aa;
var i:integer;
begin
  i:=0;
end;然后在客户端上写:
procedure TForm1.Button5Click(Sender: TObject);
begin
  ClientDM.SocketConnection1.AppServer.aa;
end;运行时出错提示:method 'aa' not supported by automation object
意思是:自动化对象‘aa’不支持的方法[Dotranslation]请问这样调用对不对?有什么方法能调用应用服务器上的东东,是不是都要求写成对象方式,在对象里定义过程,然后才能调用?

解决方案 »

  1.   

    对不起,看错了!  TMyServer是不是实现IXXX接口的类,我在这边试了一下没问题!应用服务器
    type
      TDEMO = class(TRemoteDataModule, IDEMO)
      private
        { Private declarations }
      protected
        class procedure UpdateRegistry(Register: Boolean; const ClassID, ProgID: string); override;
        procedure aa; safecall;
      public
        { Public declarations }
      end;implementation{$R *.DFM}class procedure TDEMO.UpdateRegistry(Register: Boolean; const ClassID, ProgID: string);
    begin
      if Register then
      begin
        inherited UpdateRegistry(Register, ClassID, ProgID);
        EnableSocketTransport(ClassID);
        EnableWebTransport(ClassID);
      end else
      begin
        DisableSocketTransport(ClassID);
        DisableWebTransport(ClassID);
        inherited UpdateRegistry(Register, ClassID, ProgID);
      end;
    end;procedure TDEMO.aa;
    var
      i: integer;
    begin
      showmessage('');
    end;initialization
      TComponentFactory.Create(ComServer, TDEMO,
        Class_DEMO, ciMultiInstance, tmApartment);
    end.
    客户端
    uses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      MCForms, StdCtrls, Db, DBClient, MConnect, SConnect;type
      TForm1 = class(TMCForm)
        SocketConnection1: TSocketConnection;
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { 私有成员(变量、函数)声明 }
      public
        { 公共成员(变量、函数)声明 }
      end;var
      Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
    begin
      SocketConnection1.Connected := True;
      SocketConnection1.AppServer.aa;
    end;
      

  2.   

    1.服务器上要运行scktsrvr.exe,才能执行下边的语句.
      SocketConnection1.Connected := True;
      SocketConnection1.AppServer.aa;
    2.新增加方法后,服务器程序是否注册(注册时最好将scktsrvr.exe关闭,否则新增的方法还是不能用).
      

  3.   

    http://topic.csdn.net/T/20060622/16/4837329.html看这一贴
      

  4.   

    旺仔,我看了贴了,但我在我的这里运行通不过,卡在
    procedure TForm1.Button5Click(Sender: TObject);
    var
          I:   integer;
          ADisp:IMyServerDisp;
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~(卡在这里)
      begin
          {
          SocketConnection1.AppServer.GetValue(I);
          ShowMessage(IntToStr(I));}   //这样肯定可以得到
          ADisp:=IMyServerDisp(IDispatch(ClientDM.SocketConnection1.AppServer));
          ADisp.GetValue(I);
          ShowMessage(IntToStr(I));
    end;
      

  5.   

    // *********************************************************************//
    // DispIntf:  IMyServerDisp
    // Flags:     (4416) Dual OleAutomation Dispatchable
    // GUID:      {8C38FADF-0665-4DFB-A71C-837162CDD4B8}
    // *********************************************************************//
      IMyServerDisp = dispinterface这是我的Project1_TLB.pas自动生成的