locked
Problem with RTD server created as exe with c++ (works with excel 2013 but not earlier versions) RRS feed

  • Question

  • Hi

    I am seeing a strange problem when trying to create a RTD server as an exe (C++/MFC/ATL)  and hope someone can figure out why or at least what needs to be changed to have it work.

    The rtd server works as expected with excel 2013 but fails with earlier versions.

    Where it gets stranger is that it does work with earlier versions of excel IF excel 2013 is also installed on the same computer (simply leaving excel.exe in place is sufficient.)

    When it works the com server exe is successfully launched and ServerStart is called.

    When it fails, the com server is successfully launched but ServerStart is never called and the program exits.

    I have built a bare bones application showing the problem, which is also easy to create (steps listed below).

    I have seen the same problem on different version of windows, 32 or 64 bit and building the project with different versions of c++ (using vs 2015).

    Any help would be appreciated.

    Leo

    Steps to replicate the problem.

    In visual studio choose new project / mfc application

    Change:

    application type to single document

    uncheck document / view architecture support

    build.

    Under properties / general I am using character set / use mutibyte

    Right click project, choose add class / atl / add atl support to mfc

    Right click project and choose add class /atl simple object which will be the rtd server give it an appropriate name and a progID such as rtdProblem and click finish.

    Right click the class and choose add / implement interface, choose file, select excel.exe and select IRtdServer to implement and click finish.

    To avoid build errors  open stdafx.h and comment out the import for excel and just include what is needed for irtdserver, i.e.

    --

    extern "C" const GUID __declspec(selectany) LIBID_Excel =

    { 0x00020813,0x0000,0x0000,{ 0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46 } };

     

    struct __declspec(uuid("ec0e6191-db51-11d3-8f3e-00c04f3651b8"))

                    IRtdServer : IDispatch

    {

                    //

                    // Raw methods provided by interface

                    //

     

                    virtual HRESULT __stdcall ServerStart(

                    /*[in]*/ struct IRTDUpdateEvent * CallbackObject,

                                    /*[out,retval]*/ long * pfRes) = 0;

                    virtual HRESULT __stdcall ConnectData(

                                    /*[in]*/ long TopicID,

                                    /*[in]*/ SAFEARRAY * * Strings,

                                    /*[in,out]*/ VARIANT_BOOL * GetNewValues,

                                    /*[out,retval]*/ VARIANT * pvarOut) = 0;

                    virtual HRESULT __stdcall RefreshData(

                                    /*[in,out]*/ long * TopicCount,

                                    /*[out,retval]*/ SAFEARRAY * * parrayOut) = 0;

                    virtual HRESULT __stdcall DisconnectData(

                                    /*[in]*/ long TopicID) = 0;

                    virtual HRESULT __stdcall Heartbeat(

                                    /*[out,retval]*/ long * pfRes) = 0;

                    virtual HRESULT __stdcall ServerTerminate() = 0;

    };

    --

    That is it, the project will now compile clean.

    To show the problem, open the .cpp for the application and at the beginning of InitInstance add something like

    AfxMessageBox("InitInstance called successfully”);

    In the rtd servers .h

    Change the return E_NOTIMPLs to return S_OK

    And add something like AfxMessageBox("ServerStart!"); to ServerStart.

    Built the project and register it, i.e. projectname /regserver

    If you chose a progID such as rtdProblem, in excel enter =RTD("rtdProblem",,-100)

    If it is excel 2013 or excel 2013 is installed both messageboxes will be displayed.

    If it is an earlier version of excel and excel 2013 is not present or renamed it will fail, i.e.

    the initInstance message box will be displayed and the program will exit.


    
    
    Monday, August 24, 2015 8:40 AM

Answers

  • Hi

    Never mind, looking again at the generated code I missed that the major and minor versions in the IDispatchImpl for IRtdServer had been set at 1 8. Changing them to 1 0 solves the problem...

    Leo

    Monday, August 31, 2015 7:47 AM

All replies

  • Thank you for posting in the MSDN Forum.
     
    I'm trying to involve some senior engineers into this issue and it will take some time. Your patience will be greatly appreciated.
     
    Sorry for any inconvenience and have a nice day!
    Thursday, August 27, 2015 9:15 AM
  • Hi

    Never mind, looking again at the generated code I missed that the major and minor versions in the IDispatchImpl for IRtdServer had been set at 1 8. Changing them to 1 0 solves the problem...

    Leo

    Monday, August 31, 2015 7:47 AM