OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
From: Mohammad Saleem (mohammad.saleemMAMEA.SE)
Date: Mon May 06 2002 - 02:04:37 CDT

  • Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

    Hi all,

    I am facing problem of accessing attributes of DCOM object.
    I try to explain my problem with a simple example.

    I have a server running on a machine which implements a DCOM sever
    implementing interface say "IHello".
    A client running on other machine creates this DCOM object.
    Once DCOM object is created on server side it starts communicating with
    other objects in the sever application. For this purpose I need to declare
    some my own methods like "SetValue()" as describle below in the example.

    **********************************************

    // CHello.h

     class ATL_NO_VTABLE CHello :
    public CComObjectRootEx<CComSingleThreadModel>,
    public CComCoClass<CHello , &CLSID_CHello >,
    public ISupportErrorInfo,
    public IHello
    {
    public:
            CHello ();
            virtual ~CHello ();

                    DECLARE_CLASSFACTORY_SINGLETON(CHello)

                    DECLARE_REGISTRY_RESOURCEID(IDR_HELLO)
                    DECLARE_NOT_AGGREGATABLE(CHello )

                    DECLARE_PROTECT_FINAL_CONSTRUCT()

                    BEGIN_COM_MAP(CHello )
                    COM_INTERFACE_ENTRY(ICHello )
                    COM_INTERFACE_ENTRY(ISupportErrorInfo)
                    END_COM_MAP()

                    // ISupportsErrorInfo
                    STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);

                    // IHELLO

                    STDMETHOD(Foo)();
                    STDMETHOD(Bar)();
                    ........

                    // Own methods

                    void Setvalue(int& x);

                    protected:

                    private:

                    int value;
                    .........
    };

    // CHello.cpp

    void
    CHello::Setvalue(int& x)
    {
            value = x; // do this line a client gets hr != 0x00000 (HRESULT hr)
    }
    ************************************************************

    I get error when I call "SetValue(int& x)" method.
    When I try to debug I cannot access the attributes of "CHello" class.
    I the debugger, every attribute has an error:

    "CXX0030: Error expression cannot be evaluated"

    I the same way if I declare an extern variable in CHello.h file, to be able
    to access from other file like:

    extern CComPtr<ICallbackEvent> event_m;
    I get the following error:
    ***************************************************
    error LNK2001: unresolved external symbol "class ATL::CComPtr<struct
    ICallbackEvent> event_m" (?event_m3V?$CComPtrICallbackEventATLA)
    Debug/CCS.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.
    ********************************************************

    Why it is so? Am I missing something?

    My server application project is created with ATL wizard and then I add my
    own idl file.

    Any comment or idea?
    Eargerly waiting for relpy.

    regards
    /Saleem

    ----------------------------------------------------------------
    Users Guide http://discuss.microsoft.com/archives/mailfaq.asp
    contains important info. Save time, search the archives at
    http://discuss.microsoft.com/archives/index.html .
    To unsubscribe, mailto:DCOM-signoff-requestDISCUSS.MICROSOFT.COM