今天做一段DEMO时遇到一个非常严重的问题!
interface not supported??????
客户端调用服务器端接口时产生异常!
源码如下:
服务器端:
---------------------------------------------------------------
unit Project1_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 2004-12-18 10:22:18 from Type Library described below.// ************************************************************************ //
// Type Lib: F:\test\COMTest\Server\Project1.tlb (1)
// LIBID: {3BFDC776-6385-4BF6-881F-43AFA41676AB}
// LCID: 0
// Helpfile:
// HelpString: Project1 Library
// DepndLst:
// (1) v2.0 stdole, (C:\WINNT\System32\stdole2.tlb)
// (2) v1.0 Midas, (C:\WINNT\system32\midas.dll)
// (3) v4.0 StdVCL, (C:\WINNT\system32\stdvcl40.dll)
// ************************************************************************ //
{$TYPEDADDRESS OFF} // Unit must be compiled without type-checked pointers.
{$WARN SYMBOL_PLATFORM OFF}
{$WRITEABLECONST ON}
{$VARPROPSETTER ON}
interfaceuses Windows, ActiveX, Classes, Graphics, Midas, 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
Project1MajorVersion = 1;
Project1MinorVersion = 0; LIBID_Project1: TGUID = '{3BFDC776-6385-4BF6-881F-43AFA41676AB}'; IID_Iaaaaaaaaaaaaa: TGUID = '{1A038840-990B-44F1-8071-D0EB1FA47BC2}';
CLASS_aaaaaaaaaaaaa: TGUID = '{1C05EDB1-B8C0-438E-801F-CA4E4944CFBA}';
type// *********************************************************************//
// Forward declaration of types defined in TypeLibrary
// *********************************************************************//
Iaaaaaaaaaaaaa = interface;
IaaaaaaaaaaaaaDisp = dispinterface;// *********************************************************************//
// Declaration of CoClasses defined in Type Library
// (NOTE: Here we map each CoClass to its Default Interface)
// *********************************************************************//
aaaaaaaaaaaaa = Iaaaaaaaaaaaaa;
// *********************************************************************//
// Interface: Iaaaaaaaaaaaaa
// Flags: (4416) Dual OleAutomation Dispatchable
// GUID: {1A038840-990B-44F1-8071-D0EB1FA47BC2}
// *********************************************************************//
Iaaaaaaaaaaaaa = interface(IAppServer)
['{1A038840-990B-44F1-8071-D0EB1FA47BC2}']
procedure bbb(var o: OleVariant); safecall;
end;// *********************************************************************//
// DispIntf: IaaaaaaaaaaaaaDisp
// Flags: (4416) Dual OleAutomation Dispatchable
// GUID: {1A038840-990B-44F1-8071-D0EB1FA47BC2}
// *********************************************************************//
IaaaaaaaaaaaaaDisp = dispinterface
['{1A038840-990B-44F1-8071-D0EB1FA47BC2}']
procedure bbb(var o: OleVariant); dispid 301;
function AS_ApplyUpdates(const ProviderName: WideString; Delta: OleVariant; MaxErrors: Integer;
out ErrorCount: Integer; var OwnerData: OleVariant): OleVariant; dispid 20000000;
function AS_GetRecords(const ProviderName: WideString; Count: Integer; out RecsOut: Integer;
Options: Integer; const CommandText: WideString; var Params: OleVariant;
var OwnerData: OleVariant): OleVariant; dispid 20000001;
function AS_DataRequest(const ProviderName: WideString; Data: OleVariant): OleVariant; dispid 20000002;
function AS_GetProviderNames: OleVariant; dispid 20000003;
function AS_GetParams(const ProviderName: WideString; var OwnerData: OleVariant): OleVariant; dispid 20000004;
function AS_RowRequest(const ProviderName: WideString; Row: OleVariant; RequestType: Integer;
var OwnerData: OleVariant): OleVariant; dispid 20000005;
procedure AS_Execute(const ProviderName: WideString; const CommandText: WideString;
var Params: OleVariant; var OwnerData: OleVariant); dispid 20000006;
end;// *********************************************************************//
// The Class Coaaaaaaaaaaaaa provides a Create and CreateRemote method to
// create instances of the default interface Iaaaaaaaaaaaaa exposed by
// the CoClass aaaaaaaaaaaaa. The functions are intended to be used by
// clients wishing to automate the CoClass objects exposed by the
// server of this typelibrary.
// *********************************************************************//
Coaaaaaaaaaaaaa = class
class function Create: Iaaaaaaaaaaaaa;
class function CreateRemote(const MachineName: string): Iaaaaaaaaaaaaa;
end;implementationuses ComObj;class function Coaaaaaaaaaaaaa.Create: Iaaaaaaaaaaaaa;
begin
Result := CreateComObject(CLASS_aaaaaaaaaaaaa) as Iaaaaaaaaaaaaa;
end;class function Coaaaaaaaaaaaaa.CreateRemote(const MachineName: string): Iaaaaaaaaaaaaa;
begin
Result := CreateRemoteComObject(MachineName, CLASS_aaaaaaaaaaaaa) as Iaaaaaaaaaaaaa;
end;end.
------------------------------------------------------------
unit Unit2;{$WARN SYMBOL_PLATFORM OFF}interfaceuses
Windows, Messages, SysUtils, Classes, ComServ, ComObj, VCLCom, DataBkr,
DBClient, Project1_TLB, StdVcl;type
Taaaaaaaaaaaaa = class(TRemoteDataModule, Iaaaaaaaaaaaaa)
private
{ Private declarations }
protected
class procedure UpdateRegistry(Register: Boolean; const ClassID, ProgID: string); override;
procedure bbb(var o: OleVariant); safecall;
public
{ Public declarations }
end;implementation{$R *.DFM}class procedure Taaaaaaaaaaaaa.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 Taaaaaaaaaaaaa.bbb(var o: OleVariant);
begin
o := 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
end;initialization
TComponentFactory.Create(ComServer, Taaaaaaaaaaaaa,
Class_aaaaaaaaaaaaa, ciMultiInstance, tmApartment);
end.
interface not supported??????
客户端调用服务器端接口时产生异常!
源码如下:
服务器端:
---------------------------------------------------------------
unit Project1_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 2004-12-18 10:22:18 from Type Library described below.// ************************************************************************ //
// Type Lib: F:\test\COMTest\Server\Project1.tlb (1)
// LIBID: {3BFDC776-6385-4BF6-881F-43AFA41676AB}
// LCID: 0
// Helpfile:
// HelpString: Project1 Library
// DepndLst:
// (1) v2.0 stdole, (C:\WINNT\System32\stdole2.tlb)
// (2) v1.0 Midas, (C:\WINNT\system32\midas.dll)
// (3) v4.0 StdVCL, (C:\WINNT\system32\stdvcl40.dll)
// ************************************************************************ //
{$TYPEDADDRESS OFF} // Unit must be compiled without type-checked pointers.
{$WARN SYMBOL_PLATFORM OFF}
{$WRITEABLECONST ON}
{$VARPROPSETTER ON}
interfaceuses Windows, ActiveX, Classes, Graphics, Midas, 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
Project1MajorVersion = 1;
Project1MinorVersion = 0; LIBID_Project1: TGUID = '{3BFDC776-6385-4BF6-881F-43AFA41676AB}'; IID_Iaaaaaaaaaaaaa: TGUID = '{1A038840-990B-44F1-8071-D0EB1FA47BC2}';
CLASS_aaaaaaaaaaaaa: TGUID = '{1C05EDB1-B8C0-438E-801F-CA4E4944CFBA}';
type// *********************************************************************//
// Forward declaration of types defined in TypeLibrary
// *********************************************************************//
Iaaaaaaaaaaaaa = interface;
IaaaaaaaaaaaaaDisp = dispinterface;// *********************************************************************//
// Declaration of CoClasses defined in Type Library
// (NOTE: Here we map each CoClass to its Default Interface)
// *********************************************************************//
aaaaaaaaaaaaa = Iaaaaaaaaaaaaa;
// *********************************************************************//
// Interface: Iaaaaaaaaaaaaa
// Flags: (4416) Dual OleAutomation Dispatchable
// GUID: {1A038840-990B-44F1-8071-D0EB1FA47BC2}
// *********************************************************************//
Iaaaaaaaaaaaaa = interface(IAppServer)
['{1A038840-990B-44F1-8071-D0EB1FA47BC2}']
procedure bbb(var o: OleVariant); safecall;
end;// *********************************************************************//
// DispIntf: IaaaaaaaaaaaaaDisp
// Flags: (4416) Dual OleAutomation Dispatchable
// GUID: {1A038840-990B-44F1-8071-D0EB1FA47BC2}
// *********************************************************************//
IaaaaaaaaaaaaaDisp = dispinterface
['{1A038840-990B-44F1-8071-D0EB1FA47BC2}']
procedure bbb(var o: OleVariant); dispid 301;
function AS_ApplyUpdates(const ProviderName: WideString; Delta: OleVariant; MaxErrors: Integer;
out ErrorCount: Integer; var OwnerData: OleVariant): OleVariant; dispid 20000000;
function AS_GetRecords(const ProviderName: WideString; Count: Integer; out RecsOut: Integer;
Options: Integer; const CommandText: WideString; var Params: OleVariant;
var OwnerData: OleVariant): OleVariant; dispid 20000001;
function AS_DataRequest(const ProviderName: WideString; Data: OleVariant): OleVariant; dispid 20000002;
function AS_GetProviderNames: OleVariant; dispid 20000003;
function AS_GetParams(const ProviderName: WideString; var OwnerData: OleVariant): OleVariant; dispid 20000004;
function AS_RowRequest(const ProviderName: WideString; Row: OleVariant; RequestType: Integer;
var OwnerData: OleVariant): OleVariant; dispid 20000005;
procedure AS_Execute(const ProviderName: WideString; const CommandText: WideString;
var Params: OleVariant; var OwnerData: OleVariant); dispid 20000006;
end;// *********************************************************************//
// The Class Coaaaaaaaaaaaaa provides a Create and CreateRemote method to
// create instances of the default interface Iaaaaaaaaaaaaa exposed by
// the CoClass aaaaaaaaaaaaa. The functions are intended to be used by
// clients wishing to automate the CoClass objects exposed by the
// server of this typelibrary.
// *********************************************************************//
Coaaaaaaaaaaaaa = class
class function Create: Iaaaaaaaaaaaaa;
class function CreateRemote(const MachineName: string): Iaaaaaaaaaaaaa;
end;implementationuses ComObj;class function Coaaaaaaaaaaaaa.Create: Iaaaaaaaaaaaaa;
begin
Result := CreateComObject(CLASS_aaaaaaaaaaaaa) as Iaaaaaaaaaaaaa;
end;class function Coaaaaaaaaaaaaa.CreateRemote(const MachineName: string): Iaaaaaaaaaaaaa;
begin
Result := CreateRemoteComObject(MachineName, CLASS_aaaaaaaaaaaaa) as Iaaaaaaaaaaaaa;
end;end.
------------------------------------------------------------
unit Unit2;{$WARN SYMBOL_PLATFORM OFF}interfaceuses
Windows, Messages, SysUtils, Classes, ComServ, ComObj, VCLCom, DataBkr,
DBClient, Project1_TLB, StdVcl;type
Taaaaaaaaaaaaa = class(TRemoteDataModule, Iaaaaaaaaaaaaa)
private
{ Private declarations }
protected
class procedure UpdateRegistry(Register: Boolean; const ClassID, ProgID: string); override;
procedure bbb(var o: OleVariant); safecall;
public
{ Public declarations }
end;implementation{$R *.DFM}class procedure Taaaaaaaaaaaaa.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 Taaaaaaaaaaaaa.bbb(var o: OleVariant);
begin
o := 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
end;initialization
TComponentFactory.Create(ComServer, Taaaaaaaaaaaaa,
Class_aaaaaaaaaaaaa, ciMultiInstance, tmApartment);
end.
========================================================
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,Project1_TLB, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var i : Iaaaaaaaaaaaaa;
o : olevariant;
begin
i := Coaaaaaaaaaaaaa.CreateRemote('lj'); //执行该句的时候出现的interface not supported异常!
i.bbb(o);
showmessage(o);
end;
end.这是怎么回事,在网上查了好多资料都没解决!
上面的代码在客户端与服务器端在同一计算机上时运行正常!
但将客户端迁移到另外一台计算机上时就出现interface not supported异常!也将应用中间层服务器拷贝到客户端注过册了!(运行了一次后就删除,不然客户端会调用刚才拷贝过去的中间层)但还是不行!这次死得毛都没得了!我在网上查了一下资料
很多人都说是权限问题造成的!但我们公司的网络没有域!
我怎么在DCOM中添加服务器用户?大家在此介绍一下DCOM的设置经验吧!另外像上面的代码有没有可能转换为SOCKET连接来实现
(SOCKET没有interface not supported这个问题)?
我在三台机子联机调试成功。
client(win2000 professional) + Server(win2000 Server) + Data(SQL Server 2000)先决条件:将midas.dll 拷贝一份在应用服务器的
windows\system32\ (nt版本在system32,window9x在window\system\)
如果你的客户端安装了delphi 在window\system32\ 已经有了。否则也要拷贝。1. 运行NT服务器上的dcomcnfg程序,进行DCOM配置。
2. 进入DCOM的总体默认属性页面,将“在这台计算机上启用分布式COM”打上勾,将默认身份级别改为“无”。
3. 进入DCOM的总体默认安全机制页面,确认默认访问权限和默认启动权限中的默认值无EveryOne,如果不去掉EveryOne,应用服务器不能正常启动。
4.在常规页面中,双击你的应用服务器,打开你的应用服务器DCOM属性设置。
5.将常规页面中的身份验证级别改为“无”。
6.位置页面中选上“在这台计算机上运行应用程序”。
7.将安全性页面设置中,均选择“使用自定义访问权限”,编辑每一个权限,将EveryOne加入用户 //忽略权限,正式使用时要考虑安全列表中。
8.身份标识页面中,选择“交互式用户”。
9.NT的GUEST用户不能禁用。
*10.将客户端的网关设为应用服务器所在机器的IP祝你好运。