环境如下:
1。COM+组件安装在WIN2000 SERVER上。
2。在WIN2000专业版上开发客户端,引用了COM+组件的类型库PAS,在用CreateRemoteObject创建COM+对象时提示'Interface not supported'错误。后来调用CoCreateInstanceEx来创建COM+对象,发现对象创建成功,得到的引用是IUnknown的接口,于是用as 或 queryInterface来取实现的接口,就提示上述的错误,服务器端的COM+组件已被激活。请各位高手指点。这个问题困了我几天了。解决了再加100分。
1。COM+组件安装在WIN2000 SERVER上。
2。在WIN2000专业版上开发客户端,引用了COM+组件的类型库PAS,在用CreateRemoteObject创建COM+对象时提示'Interface not supported'错误。后来调用CoCreateInstanceEx来创建COM+对象,发现对象创建成功,得到的引用是IUnknown的接口,于是用as 或 queryInterface来取实现的接口,就提示上述的错误,服务器端的COM+组件已被激活。请各位高手指点。这个问题困了我几天了。解决了再加100分。
wangfajun521(阿发) 你遇到这问题能想想是怎么搞好的吗?
unit PMtsCOMLogic_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 2006-10-27 11:33:13 from Type Library described below.// ************************************************************************ //
// Type Lib: E:\work\COM\logic\PMtsCOMLogic.tlb (1)
// LIBID: {E4D7CC3B-8963-4061-90FB-1988294B9C07}
// LCID: 0
// Helpfile:
// HelpString: PMtsCOMLogic Library
// DepndLst:
// (1) v2.0 stdole, (C:\WINNT\system32\stdole2.tlb)
// ************************************************************************ //
{$TYPEDADDRESS OFF} // Unit must be compiled without type-checked pointers.
{$WARN SYMBOL_PLATFORM OFF}
{$WRITEABLECONST ON}
{$VARPROPSETTER ON}
interfaceuses Windows, ActiveX, Classes, Graphics, 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
PMtsCOMLogicMajorVersion = 1;
PMtsCOMLogicMinorVersion = 0; LIBID_PMtsCOMLogic: TGUID = '{E4D7CC3B-8963-4061-90FB-1988294B9C07}'; IID_IMtsCom: TGUID = '{EEE809A6-F919-43CD-8CDD-2B0788237308}';
CLASS_MtsCom: TGUID = '{A2B6F4B3-3671-4FCD-B057-6886E75D36B1}';
type// *********************************************************************//
// Forward declaration of types defined in TypeLibrary
// *********************************************************************//
IMtsCom = interface;
IMtsComDisp = dispinterface;// *********************************************************************//
// Declaration of CoClasses defined in Type Library
// (NOTE: Here we map each CoClass to its Default Interface)
// *********************************************************************//
MtsCom = IMtsCom;
// *********************************************************************//
// Interface: IMtsCom
// Flags: (4416) Dual OleAutomation Dispatchable
// GUID: {EEE809A6-F919-43CD-8CDD-2B0788237308}
// *********************************************************************//
IMtsCom = interface(IDispatch)
['{EEE809A6-F919-43CD-8CDD-2B0788237308}']
procedure Login(const sName: WideString; const sPassword: WideString; var vCookie: OleVariant); safecall;
procedure GetBooks(vCookie: OleVariant; var vDatas: OleVariant); safecall;
procedure GetDataCount(var ACount: OleVariant); safecall;
function GetStr: OleVariant; safecall;
procedure UpdateJob(const ASQL: IMtsCom); safecall;
function Get_Desc: WideString; safecall;
procedure Set_Desc(const Value: WideString); safecall;
function Get_Min_Lvl: SYSINT; safecall;
procedure Set_Min_Lvl(Value: SYSINT); safecall;
function Get_Max_Lvl: SYSINT; safecall;
procedure Set_Max_Lvl(Value: SYSINT); safecall;
property Desc: WideString read Get_Desc write Set_Desc;
property Min_Lvl: SYSINT read Get_Min_Lvl write Set_Min_Lvl;
property Max_Lvl: SYSINT read Get_Max_Lvl write Set_Max_Lvl;
end;// *********************************************************************//
// DispIntf: IMtsComDisp
// Flags: (4416) Dual OleAutomation Dispatchable
// GUID: {EEE809A6-F919-43CD-8CDD-2B0788237308}
// *********************************************************************//
IMtsComDisp = dispinterface
['{EEE809A6-F919-43CD-8CDD-2B0788237308}']
procedure Login(const sName: WideString; const sPassword: WideString; var vCookie: OleVariant); dispid 201;
procedure GetBooks(vCookie: OleVariant; var vDatas: OleVariant); dispid 202;
procedure GetDataCount(var ACount: OleVariant); dispid 203;
function GetStr: OleVariant; dispid 204;
procedure UpdateJob(const ASQL: IMtsCom); dispid 205;
property Desc: WideString dispid 206;
property Min_Lvl: SYSINT dispid 207;
property Max_Lvl: SYSINT dispid 208;
end;// *********************************************************************//
// The Class CoMtsCom provides a Create and CreateRemote method to
// create instances of the default interface IMtsCom exposed by
// the CoClass MtsCom. The functions are intended to be used by
// clients wishing to automate the CoClass objects exposed by the
// server of this typelibrary.
// *********************************************************************//
CoMtsCom = class
class function Create: IMtsCom;
class function CreateRemote(const MachineName: string): IMtsCom;
end;implementationuses ComObj;class function CoMtsCom.Create: IMtsCom;
begin
Result := CreateComObject(CLASS_MtsCom) as IMtsCom;
end;class function CoMtsCom.CreateRemote(const MachineName: string): IMtsCom;
begin
Result := CreateRemoteComObject(MachineName, CLASS_MtsCom) as IMtsCom;
end;end.
MyComObj: IMtsCom;
ACount: OleVariant;
begin
MyComObj := MtsCom.CreateRemote('YourMachineName');
MyComObj.GetDataCount(ACount);
...
end;
MyComObj: IMtsCom;
ACount: OleVariant;
begin
MyComObj := CoMtsCom.CreateRemote('YourMachineName'); //不能用MtsCom
...
class function CreateRemote(const MachineName: string): IMtsCom;2个类函数返回的类型才是IMtsCom
在自己没有做测试或弄通原理之前,请不要太随意发表言论。你可能从来没有亲手写过COM+吧,所以才会发表上述言语。
var
MyComObj: IMtsCom;
ACount: OleVariant;
begin
MyComObj := MtsCom.CreateRemote('YourMachineName');
MyComObj.GetDataCount(ACount);
...
end;因为, CreateRemote 是这么定义的
class function CoMtsCom.CreateRemote(const MachineName: string): IMtsCom;
begin
Result := CreateRemoteComObject(MachineName, CLASS_MtsCom) as IMtsCom;
end;com/dcom/mts/com+ 这系列都是是一种关系, 这个关系明确, dcom 是一种 com, 带有远程带理的 commts 是一种 dcom, 带有事务支持的 dcom(代理上), IObjectControl, IObjectContext, 就是说基本上任何 dcom 对像都可以在 mts 上安装, 你不一定要实事 IObjectControlcom+ 是一种 mts, mts 定义了池化却没有实现, com+ 是一个实现了 mts 所有定义的版本
晕菜, 你哪根葱啊, 怎么这世道就半桶水的人最冲啊
事实上那个错误会导致编译不通过:
因为:
MtsCom = IMtsCom;
而IMtsCom接口中根本就没有CreateRemote这个成员函数,并且接口的成员函数根本不可以这样调用。
如果如楼主所说,在本机正常,REMOTE访问不正常,所以这只能解释为楼主的笔误,实际的问题所在正如太可怕所说的那样。TO:老冯
自已不会就好好听听别人的意见。这么大把年纪知不知道什么叫做虚心?知不知道什么叫做尊重?
像楼主这样的问题,每个做COM+的程序员刚开始几乎都会碰到,可以负责任地告诉你:太可怕的星星里有很大一部分就是因为回答COM相关的问题得来的。
也别动不动就社区如何如何,社区如今的现状正是像你这种人造成的。
不就是抢分嘛,楼主把分给冯老师好了。
我早就说过:
分~就素那浮云~~
现在企业级中间件可选的东东真的是不多了