cant access object methode in HTML script

i use ATL to build a project like this,

[
object,
uuid("0D508BA2-FBD9-4F27-B5B4-FBC88B2F1D72"),
dual,
helpstring("IDataSource Interface"),
pointer_default(unique)
]
__interface IDataSource : IDispatch
{

[id(1), helpstring("method Connect")] HRESULT Connect([in] BSTR ConnectString, [out,retval] VARIANT_BOOL* retVal);
[id(2), helpstring("method GetSession")] HRESULT GetSession([out,retval] LONG* retVal);
};

[
object,
uuid("55A20CF6-A0FD-4611-992F-B72FE0FB68C2"),
dual, helpstring("ISQLDataSource Interface"),
pointer_default(unique)
]
__interface ISQLDataSource : IDataSource <-- i'm not sure if it's correct
{
};

after i implementted the Connect methode, i tried to test it in a javascript,

obj.Connect("***")

but i got a error message indicating me that, this object does not support this methode.
later, i tried to test it in vb.net, and it passed, how strange...what caused this problem




Answer this question

cant access object methode in HTML script

  • sweet_dreams

    DavidShen wrote:

    i use ATL to build a project like this,

    [
    object,
    uuid("0D508BA2-FBD9-4F27-B5B4-FBC88B2F1D72"),
    dual,
    helpstring("IDataSource Interface"),
    pointer_default(unique)
    ]
    __interface IDataSource : IDispatch
    {

    [id(1), helpstring("method Connect")] HRESULT Connect([in] BSTR ConnectString, [out,retval] VARIANT_BOOL* retVal);
    [id(2), helpstring("method GetSession")] HRESULT GetSession([out,retval] LONG* retVal);
    };

    [
    object,
    uuid("55A20CF6-A0FD-4611-992F-B72FE0FB68C2"),
    dual, helpstring("ISQLDataSource Interface"),
    pointer_default(unique)
    ]
    __interface ISQLDataSource : IDataSource <-- i'm not sure if it's correct
    {
    };

    after i implementted the Connect methode, i tried to test it in a javascript,

    obj.Connect("***")

    but i got a error message indicating me that, this object does not support this methode.
    later, i tried to test it in vb.net, and it passed, how strange...what caused this problem

    Not a solution, but a way to find out what's going on. I had this problem a few months ago, when I was trying to test a COM (written in Win32 C++, without ATL/MFC) method via DHTML. Although everything worked when I called the COM method in C#, in DHTML, I always got the error "Automation server cannot create object" in Internet Explorer.

    To debug the problem in Visual C++, I created my DHTML test page at C:\test\comobjtest.html, then in the project property pages for the COM project, I went to:

    • Debugging -> Command -> Set to iexplore.exe
    • Command Arguments -> Set to C:\test\comobjtest.html
    • Directory -> Set to the C:\test

    Then I put debug breakpoints at the start of all my functions. When I started debugging (with F5), Visual C++ started Internet explorer, which loaded up the comobjtest.html page, whose script called into our COM object, and hit the breakpoints to my functions.

    Now I could figure out why IE was failing on my COM object (in my case, it was due to an improper implementation of IDispatch). ATL might be a bit tougher to debug than normal C++, but it should still be doable if you enable the disassembly window.



  • Davd Munger

    thx for reply!

    i think my problem is also a improper implementation of the IDispatch, but ATL is too~~ complicate. i just changed my app, so to avoid it :(



  • cant access object methode in HTML script