Announcement

Collapse
No announcement yet.

Class does not support Automation or does not support expected interface

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Class does not support Automation or does not support expected interface

    Does any one has an idea what this is and how I solve it.

    The object is a COM object (duh) and works perfectly in PowerBasic and is also
    written in PowerBasic 9.0 but when I try to instantiate the object in another script language I get this error

    'Class does not support Automation or does not support expected interface'

    I search high and low but I don't get a satisfied answer from the posting I've read.

    Thanks

    Steven
    So here we are, this is the end.
    But all that dies, is born again.
    - From The Ashes (In This Moment)

  • #2
    What does the IDL file look like?
    Dominic Mitchell
    Phoenix Visual Designer
    http://www.phnxthunder.com

    Comment


    • #3
      ??? IDL with PowerBasic ? Sorry, I'm lost...
      So here we are, this is the end.
      But all that dies, is born again.
      - From The Ashes (In This Moment)

      Comment


      • #4
        Most scripting languages do not support an IAutomation interface and only support IDispatch interfaces. You should be Inheriting IDual so that the interface supports both Direct VTable calls and Dispatch calls.
        Last edited by Steve Rossell; 16 Oct 2008, 10:08 AM.
        Sincerely,

        Steve Rossell
        PowerBASIC Staff

        Comment


        • #5
          Thank you Steve, I'll check that.

          Sincerely
          Steven
          So here we are, this is the end.
          But all that dies, is born again.
          - From The Ashes (In This Moment)

          Comment


          • #6
            ??? IDL with PowerBasic ? Sorry, I'm lost...
            Interface Definition Language file is used to describe the attributes of COM objects
            and is processed by the MIDL compiler to build a type library file(*.tlb).
            Normally, an IDL file is not needed in PowerBASIC because the type library is
            created directly for you. You can get an IDL from a TLB by using a tool such as
            Microsoft's OleView, or view the contents of a TLB by using a good type library browser.

            Your interface probably only has the computed dispatchable attribute which means it inherits
            IDispatch but is not dual. In PowerBASIC, that would be an interface with this line
            Code:
            Inherit IAutomation
            For an interface with the attributes dual and oleautomation, you will need, as Steve said, this line
            Code:
            Inherit IDispatch
            By the way Steve, the PowerBASIC COM browser does not distinguish between an interface that is
            merely dispatchable and one that is dual.
            Last edited by Dominic Mitchell; 16 Oct 2008, 03:31 PM.
            Dominic Mitchell
            Phoenix Visual Designer
            http://www.phnxthunder.com

            Comment


            • #7
              By the way Steve, the PowerBASIC COM browser does not distinguish between an interface that is merely dispatchable and one that is dual.
              It will if the interface is created as a Dispatch only. If it is a dual interface you can force the COM Browser to generate a dispatch interface definition by going to Tools | Options and selecting the "Generate Dispatch Interfaces Only" option. By default we figured that most users would want to use a direct VTable Interface as it is the fastest option and not a dispatch, but you can get a dispatch interface definition if you want.

              IAutomation uses direct VTable calls and is not the same as Dispatch, see http://www.powerbasic.com/support/he...ase_Class_.htm for a definition of all interface types.

              For a scripting language you will want to use Inherit Dual and not Inherit IAutomation.
              Sincerely,

              Steve Rossell
              PowerBASIC Staff

              Comment


              • #8
                It will if the interface is created as a Dispatch only. If it is a dual interface you can force the COM Browser to generate a dispatch interface definition by going...
                That is not what I was alluding to.

                Given the following IDL
                Code:
                [
                 odl,
                 uuid(D1B6F1CB-C9DA-47A1-B58A-7BF32EB62CE2)
                ]
                interface _Icon : IDispatch {
                   HRESULT _stdcall LoadBitmap([in] BSTR FileName);
                   HRESULT _stdcall LoadIcon([in] BSTR FileName);
                   [propget]
                   HRESULT _stdcall index([out, retval] long* pVal);
                   [propput]
                   HRESULT _stdcall index([in] long pVal);
                   [propput]
                   HRESULT _stdcall HBITMAP([in] unsigned long rhs);
                   [propget]
                   HRESULT _stdcall maskColor([out, retval] unsigned long* pVal);
                   [propput]
                   HRESULT _stdcall maskColor([in] unsigned long pVal);
                   [propput]
                   HRESULT _stdcall HICON([in] unsigned long rhs);
                };
                This not a dispinterface nor is it dual. It, however, is dispatchable. Its TYPEKIND would be TKIND_INTERFACE not TKIND_DISPATCH.

                The PowerBASIC COM browser generates this code
                Code:
                INTERFACE Int__Icon $IID_HOTDOCS_INT__ICON
                   Inherit IDISPATCH
                
                   Method LoadBitmap <1> (BYVAL FileName AS STRING)
                ...
                Well, according to the PB docs, this would declare a dual interface, but it is not.
                Dominic Mitchell
                Phoenix Visual Designer
                http://www.phnxthunder.com

                Comment


                • #9
                  Well, according to the PB docs, this would declare a dual interface, but it is not.
                  INHERIT IDispatch defines a dual interface when you are writing classes with PB to build a COM server, but when it is a declaration to use a server as a client, it simply defines that it is an interface that inherits from IDispatch.
                  Forum: http://www.jose.it-berater.org/smfforum/index.php

                  Comment


                  • #10
                    INHERIT IDispatch defines a dual interface when you are writing classes with PB to build a COM server, but when it is a declaration to use a server as a client, it simply defines that it is an interface that inherits from IDispatch.
                    Okay.
                    If you were writing a COM server in PB, how would you do the following?
                    Specify that the interface inherits IDispatch but has the interface attribute(TKIND_INTERFACE).
                    Specify that the interface inherits IDispatch is not dual and has the dispinterface attribute(TKIND_DISPATCH).
                    Dominic Mitchell
                    Phoenix Visual Designer
                    http://www.phnxthunder.com

                    Comment


                    • #11
                      These aren't currently supported.

                      You can write a COM server that inherits from IUnknown, IAutomation (inherits from IUnknown but follows Automation rules) and IDispatch (dual interfaces).

                      You can't write a dispatch-only COM server in PB.
                      Forum: http://www.jose.it-berater.org/smfforum/index.php

                      Comment


                      • #12
                        Well, I don't intend to write COM servers(ActiveX controls) using PB COM. For that I use
                        low-level COM which is pretty straightforward and unlimited.
                        The ability to explicitly specify attributes such as dual and oleautomation rather than
                        implicitly via the inherit keyword would have been nice.
                        Then there is the limitation in PB of one dual interface per class.
                        Dominic Mitchell
                        Phoenix Visual Designer
                        http://www.phnxthunder.com

                        Comment


                        • #13
                          Originally posted by Dominic Mitchell View Post
                          Then there is the limitation in PB of one dual interface per class.
                          If you'll just read the documentation on the COM standard, you'll find this is a strict requirement of COM, not PowerBASIC. So, PowerBASIC rightfully follows "the rules".

                          Regards,

                          Bob Zale
                          PowerBASIC Inc.

                          Comment


                          • #14
                            Okay will go check again, because what I remember is that a coclass can have more than one interface but only one can be set as the default.
                            Dominic Mitchell
                            Phoenix Visual Designer
                            http://www.phnxthunder.com

                            Comment


                            • #15
                              Originally posted by Dominic Mitchell View Post
                              Okay will go check again, because what I remember is that a coclass can have more than one interface but only one can be set as the default.
                              That's a nice observation (correct, also), but it's really no more pertinent than to say a variable may have only one value at a time. There's no connection between the two. A default interface is not necessarily a Dual interface, nor does it necessarily even support a Dispatch interface. Of course, wouldn't it be a little difficult to have two or three interfaces as the default interface?

                              Actually, you suggested that PowerBASIC was somehow less than adequate when that simply isn't factual. I'd think it would be good to try to avoid misleading your many friends here.

                              Best regards,

                              Bob Zale
                              PowerBASIC Inc.

                              Comment


                              • #16
                                Actually, you suggested that PowerBASIC was somehow less than adequate
                                I did not.
                                It's a rule that is ignored by the majority of the type libraries on my system.
                                This is probably similar to the programmatic ID length rule.
                                Dominic Mitchell
                                Phoenix Visual Designer
                                http://www.phnxthunder.com

                                Comment


                                • #17
                                  The rule is that there's one and only one IDispatch interface per object because COM uses proxy/stubs to marshal arguments between separate apartments. Some components, such CDOSYS, implement more than one dual interface in the same object (CDOSYS's Message coclass implements IMessage, IDataSource and IBodyPart). However, you will have to trick COM proxy/stubs by returning different addresses depending upon the interface from which you request IDispatch.

                                  See: http://msdn.microsoft.com/en-us/libr...EXCHG.80).aspx
                                  Forum: http://www.jose.it-berater.org/smfforum/index.php

                                  Comment


                                  • #18
                                    However, you will have to trick COM proxy/stubs by returning different addresses depending upon the interface from which you request IDispatch.
                                    Which is bad because it breaks the rules for QueryInterface.
                                    Dominic Mitchell
                                    Phoenix Visual Designer
                                    http://www.phnxthunder.com

                                    Comment

                                    Working...
                                    X