求救:著名的hello我调试时出现了问题!!(50分)

  • 主题发起人 shenglong0101
  • 开始时间
S

shenglong0101

Unregistered / Unconfirmed
GUEST, unregistred user!
一个著名的Hello程序(简单的asp组件),我在.asp中用
<% Set DelphiASPObj = Server.CreateObject("aspobjecthelloproj.aspobjecthello");
DelphiASPObj.hello();{Insert Method name here}
%>
调用时在Ie中出现了:
错误类型:
Microsoft VBScript 编译器错误 (0x800A0401)
/aspobjecthello.asp, 第 8 行, 第 75 列
Set DelphiASPObj = Server.CreateObject("aspobjecthelloproj.aspobjecthello");
--------------------------------------------------------------------------^

组件的三个程序段是:
1.
library aspobjecthelloproj;

{%File 'aspobjecthello.asp'}

uses
ComServ,
aspobjecthelloproj_TLB in 'aspobjecthelloproj_TLB.pas',
Unit1 in 'Unit1.pas' {aspobjecthello: CoClass};

exports
DllGetClassObject,
DllCanUnloadNow,
DllRegisterServer,
DllUnregisterServer;

{$R *.TLB}

{$R *.RES}

begin
end.

2.
unit Unit1;

{$WARN SYMBOL_PLATFORM OFF}

interface

uses
ComObj, ActiveX, AspTlb, aspobjecthelloproj_TLB, StdVcl;

type
Taspobjecthello = class(TASPObject, Iaspobjecthello)
protected
procedure OnEndPage; safecall;
procedure OnStartPage(const AScriptingContext: IUnknown); safecall;
procedure hello; safecall;
end;

implementation

uses ComServ;

procedure Taspobjecthello_OnEndPage;
begin
inherited OnEndPage;
end;

procedure Taspobjecthello_OnStartPage(const AScriptingContext: IUnknown);
begin
inherited OnStartPage(AScriptingContext);
end;

procedure Taspobjecthello.hello;
begin
response.Write('Hello!');

end;

initialization
TAutoObjectFactory.Create(ComServer, Taspobjecthello, Class_aspobjecthello,
ciMultiInstance, tmApartment);
end.

3.
unit aspobjecthelloproj_TLB;


interface

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


const
// TypeLibrary Major and minor versions
aspobjecthelloprojMajorVersion = 1;
aspobjecthelloprojMinorVersion = 0;

LIBID_aspobjecthelloproj: TGUID = '{C148D132-BB10-46AC-9698-5E6644D29AB4}';

IID_Iaspobjecthello: TGUID = '{68813D4F-7E6D-43F4-B824-D140F88A5F57}';
CLASS_aspobjecthello: TGUID = '{A2A2CCF0-F19C-4360-92BC-836CA9D1AE4A}';
type

// *********************************************************************//
// Forward declaration of types defined in TypeLibrary
// *********************************************************************//
Iaspobjecthello = interface;
IaspobjecthelloDisp = dispinterface;

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


// *********************************************************************//
// Interface: Iaspobjecthello
// Flags: (4416) Dual OleAutomation Dispatchable
// GUID: {68813D4F-7E6D-43F4-B824-D140F88A5F57}
// *********************************************************************//
Iaspobjecthello = interface(IDispatch)
['{68813D4F-7E6D-43F4-B824-D140F88A5F57}']
procedure OnStartPage(const AScriptingContext: IUnknown); safecall;
procedure OnEndPage; safecall;
procedure hello; safecall;
end;

// *********************************************************************//
// DispIntf: IaspobjecthelloDisp
// Flags: (4416) Dual OleAutomation Dispatchable
// GUID: {68813D4F-7E6D-43F4-B824-D140F88A5F57}
// *********************************************************************//
IaspobjecthelloDisp = dispinterface
['{68813D4F-7E6D-43F4-B824-D140F88A5F57}']
procedure OnStartPage(const AScriptingContext: IUnknown); dispid 1;
procedure OnEndPage; dispid 2;
procedure hello; dispid 3;
end;

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

implementation

uses ComObj;

class function Coaspobjecthello.Create: Iaspobjecthello;
begin
Result := CreateComObject(CLASS_aspobjecthello) as Iaspobjecthello;
end;

class function Coaspobjecthello.CreateRemote(const MachineName: string): Iaspobjecthello;
begin
Result := CreateRemoteComObject(MachineName, CLASS_aspobjecthello) as Iaspobjecthello;
end;

end.

哪位大侠解答一下!
 
怎么不见回复啊!
 
这个问题难么?
 
这个问题难么?
 
VBScript可不能用分号结束的,你第一行多了分号“;”结束
 
感谢pipi,但你指出的我早就试过了,还是解决不了,急!!
 
对了,这个注释: {Insert Method name here}
是delphi的,vbscript可不能用 { } 来注释
 
各位高手,现在的错误信息是:
错误类型:
Microsoft VBScript 编译器错误 (0x800A0401)
/aspobjecthello.asp, 第 9 行, 第 20 列
DelphiASPObj.hello();
-------------------^

请速!
 
分号去掉之后,
<% Set DelphiASPObj = Server.CreateObject("aspobjecthelloproj.aspobjecthello")
DelphiASPObj.hello()
%>
如果还出错,请帖出新的错误信息
 
不是说了吗,VBScript可不能用分号结束的
DelphiASPObj.hello()后面不能有分号";"

 
顶部