Excel RTD Servers: C# Interfaces

So it turns out that there are in fact quite a few developers who care about writing RTD servers. I’ve received a few emails asking for more information so I may post a few more entries on the subject. Last time I simply showed what the RTD server interfaces look like in C++. Here’s the equivalent in C#:

[Guid("A43788C1-D91B-11D3-8F39-00C04F3651B8")]
interface IRTDUpdateEvent
{
    void UpdateNotify();

    int HeartbeatInterval { get; set; }

    void Disconnect();
}

[Guid("EC0E6191-DB51-11D3-8F3E-00C04F3651B8")]
interface IRtdServer
{
    int ServerStart(IRTDUpdateEvent callback);

    object ConnectData(int topicId,
                       ref Array strings,
                       ref bool newValues);

    Array RefreshData(ref int topicCount);

    void DisconnectData(int topicId);

    int Heartbeat();

    void ServerTerminate();
}


Of course what these interfaces look like and how they are actually called by Excel are two very different things thanks to the horrors wonders of IDispatch.

I’m including C# in the discussion as its very tempting for .NET developers to implement an RTD server in managed code. Unfortunately it’s easy to forget that you still need to follow the rules outlined by the COM specification. If you don’t, it will come back to haunt you later on.

4 Comments

  • Great that you're continuing writing about RTD! I'm for one am following closely.

    I see the interfaces descend from IDispatch, but is RTD actually supported out-of-process (Automation style), or only in-process (COM DLL loaded by Excel)?

    Both models has their pros and cons, but are they both technically supported by RTD/Excel?

  • Hallvard Vassbotn: Yes, you can register your RTD server to run out-of-process on the local computer. You can even run it on a remote computer. Of course the .NET Framework’s COM infrastructure doesn’t support out-of-process activation, but that’s not going to stop us. Stay tuned.

  • Do you have an example of creating an RTD server in a separate process? i have your examples working if i just register them as a dll, but i would like to use dcom so my rtd server is standalone...

  • Patrick Waters: That’s the topic of an upcoming entry in the series.

Comments have been disabled for this content.