环境如下:
1。COM+组件安装在WIN2000 SERVER上。
2。在WIN2000专业版上开发客户端,引用了COM+组件的类型库PAS,在用CreateRemoteObject创建COM+对象时提示'Interface not supported'错误。后来调用CoCreateInstanceEx来创建COM+对象,发现对象创建成功,得到的引用是IUnknown的接口,于是用as 或 queryInterface来取实现的接口,就提示上述的错误,服务器端的COM+组件已被激活。请各位高手指点。这个问题困了我几天了。解决了再加100分。

解决方案 »

  1.   

    把你的类型库PAS和调用接口代码贴出来看看啦。
      

  2.   

    类型库很简单就是添加了一个方法,然后实现了,用来在客户端调用,我只是为了测试在两台机器中能不能调用.代码在公司,明天贴上.
    wangfajun521(阿发) 你遇到这问题能想想是怎么搞好的吗?
      

  3.   

    服务器端的代码如下:
    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.
      

  4.   

    var
      MyComObj: IMtsCom;
      ACount: OleVariant;
    begin
      MyComObj := MtsCom.CreateRemote('YourMachineName');
      MyComObj.GetDataCount(ACount);
      ...
    end;
      

  5.   

    var
      MyComObj: IMtsCom;
      ACount: OleVariant;
    begin
      MyComObj := CoMtsCom.CreateRemote('YourMachineName'); //不能用MtsCom
      ...
      

  6.   

    不要贴代码了, 是权限设置管理工具打开 组件服务 -> 你的程序属性中的安全叶, 最上面那个 check box 说 强制安全访问检查, 关了xp 某些版本, 有时你还得把远程的 guest 允许com+ 有时建立连接速度是慢得无法接受, 大于 40-50 机的局域网就不行, 所以不少人都用 socketconnection 代替了, 或是根本不走 ms 路线了,像 WebService 啦
      

  7.   

    你仔细看看下面的代码就明白了class function Create: IMtsCom;
    class function CreateRemote(const MachineName: string): IMtsCom;2个类函数返回的类型才是IMtsCom
      

  8.   

    comanche(太可怕) 
    在自己没有做测试或弄通原理之前,请不要太随意发表言论。你可能从来没有亲手写过COM+吧,所以才会发表上述言语。
      

  9.   

    像comanche(太可怕)这样的人怎么混到个五星的?社区真的该好好整顿了。
      

  10.   

    第一次呵呵被人攻击了, 哈哈, 还好认识在下的人应该不少了嗯, com+ 应用我还是作过一些了, 十几个应用还是有的, com+ 在建立连接后有不错的表现, 有时可以节约 20% 网络, 但建立连接过程就不怎么地了, 过多的协议尝试和安全认证在里面, 在一个较大点的子网中这个过程变得简直是不可思议, 在一个分段的子网中配置路由器也不是说打开一两个端口的问题// 我看清楚了, 这段话完全没有问题
    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 所有定义的版本
      

  11.   

    离题啊, 楼主是本机执行没问题吧, 同样用的是 CreateRemoteCOMObject 也没问题吧?这样看你可以试一下, 在两台机上都建一个有 Administrators 权限的用户名, 注意下两个机上的名字要一样, 密码也要完全一样, 应该就可以执行了
      

  12.   

    原银送还:comanche(太可怕) ( ) 
    晕菜, 你哪根葱啊, 怎么这世道就半桶水的人最冲啊
      

  13.   

    这位79年上大学的冯大叔,不可否认,你的确发现了楼主程序中的一个错误,但是你有没有试过楼主的问题是不是这个原因造成的?
    事实上那个错误会导致编译不通过:
    因为:
    MtsCom = IMtsCom;
    而IMtsCom接口中根本就没有CreateRemote这个成员函数,并且接口的成员函数根本不可以这样调用。
    如果如楼主所说,在本机正常,REMOTE访问不正常,所以这只能解释为楼主的笔误,实际的问题所在正如太可怕所说的那样。TO:老冯
    自已不会就好好听听别人的意见。这么大把年纪知不知道什么叫做虚心?知不知道什么叫做尊重?
    像楼主这样的问题,每个做COM+的程序员刚开始几乎都会碰到,可以负责任地告诉你:太可怕的星星里有很大一部分就是因为回答COM相关的问题得来的。
    也别动不动就社区如何如何,社区如今的现状正是像你这种人造成的。
    不就是抢分嘛,楼主把分给冯老师好了。
    我早就说过:
    分~就素那浮云~~
      

  14.   

    呵呵, 真是死水微澜啊。今天看到Raptor(猛禽)出来,有点诧异,一直喜欢Raptor(猛禽)的文章和BLOG。向小猛致敬。
      

  15.   

    最近一直在整理思路,闲得来社区逛逛,没有想到遇到Raptor(猛禽),难得难得。
      

  16.   

    可惜啊, com+ 可以说是历史了, 在 delphi 的接口下可以说是资源砸净了
    现在企业级中间件可选的东东真的是不多了
      

  17.   

    你在成都作项目哈, 好地方啊, PLMM 多多奇怪的是你从哪知道的资料, 我可是无 QQ, 无 blog, 无主叶的, 那猛鸟的你知道多少?哈哈, 鸟不要说我卖你啦, 估计人家连你的生辰八字都知也不一定