今天做一段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.
解决方案 »
- 关于WebBrowser使用的问题,从流中载入出问题 = = 求教高人指点
- 如何用流读取TXT文件??
- 有人在用 delphi 7 吗?有没有 wincrypt.pas 或文件名含有 crypt 的pas文件?
- TreeView的操作问题
- 哪里有介绍DELPHI优势的资料
- 一个关于字符串的问题,问了我们公司最厉害的程序员,不懂。有兴趣的话进来看一下
- 请问有DELPHI远程数据库连接方式的详细介绍
- ado-------- 主从表------------ 救急!!!!!!!!
- 菜鸟63 再次求教 全排列最优算法。
- 怎样实现数据库的备份?
- 让我头脑快短路的问题,求救啊!
- 请问:indy10里的TidTcpServer性能如何?
========================================================
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这个问题)?
我试过使用xml binding时,因为定义的元素使用大写字符(xml规定应该使用小写),通信使用小写的元素定义,delphi提示interface not supported,后来把所有元素都定义为小写就没问题了。
DCOM配置 如果在Windows NT环境下正常运行应用服务器,必须进行DCOM配置。配置方法如下: 1.运行NT服务器上的dcomcnfg程序,进行DCOM配置。 2.进入DCOM的总体默认属性页面,将“在这台计算机上启用分布式COM”打上勾,将默认
身份级别改为“无”。 3.进入DCOM的总体默认安全机制页面,确认默认访问权限和默认启动权限中的默认值无EveryOne,
如果不去掉EveryOne,应用服务器不能正常启动。 4.在常规页面中,双击你的应用服务器,打开你的应用服务器DCOM属性设置。 5.将常规页面中的身份验证级别改为“无”。 6.位置页面中选上“在这台计算机上运行应用程序”。 7.将安全性页面设置中,均选择“使用自定义访问权限”,编辑每一个权限,将EveryOne加入用
户列表中。 8.身份标识页面中,选择“交互式用户”。 9.NT的GUEST用户不能禁用。
注意:关键所在,在控制面板--用户和密码里administrators用户的属性--隶属于里添加power users,其它用户也这样做,guest用户绝对不可以禁用xp下配置
xp下和上面的一样,不过不用做上面注意里面的东西,只须在dcom配置里对我的电脑属性里的默认com安全性页里默认访问权限和默认启动权限里都加入everyone就可以了