Simple RTD Server example

1,740 views
Skip to first unread message

matt....@gmail.com

unread,
Apr 21, 2014, 12:56:28 PM4/21/14
to exce...@googlegroups.com
Hi, I have browsed through pretty much all threads regarding RTD server issues, and also tried to locate examples in the Samples/RTD folder but somehow I am still very unclear about the RTD workings within Excel DNA.

Is there a chance to post a simple RTD server example? I am not a big fan of reactive extensions (however, a very big fan of TPL Dataflow which equally well solves most data flow and streaming problems) and I wonder whether knowledge of Rx is necessary to get a simple RTD server in ExcelDNA running. 

Thanks
Matt

Govert van Drimmelen

unread,
Apr 21, 2014, 1:10:09 PM4/21/14
to exce...@googlegroups.com
Hi Matt,

The code in Distribution\Samples\RTD\ExcelRtdServer.dna is about as simple as it gets.

Some relevant points:
* You don't need to use Rx to make RTD servers with Excel-DNA. The Rx extensions are based on the RTD server support, but you can easily make your own RTD servers in an Excel-DNA add-in too.
* Derive from the ExcelRtdServer base class (in ExcelDna.Integration.Rtd) to base your RTD server on.
* Mark your class as [ComVisible(true)] (but remember to never mark your assembly as "Register for COM Interop" in Visual Studio.
* Override at least ConnectData (and probably DisconnectData) to be notified when a new topic is connected from a worksheet function.
* Store the Topic object that is passed to ConnectData, then call its UpdateValue member (as often as you want, and from any thread!) when the data should be updated.
* Make a wrapper function that looks like this:
    public static object MyRTDCall(string topicInfo)
    {
        return XlCall.RTD("MyRTDServers.MyServer", null, topicInfo);
    }
* Then call from a formula as =MyRTDCall("XYZ")

Please post back if you have any other specific questions, or run into any problems.

Regards,
Govert

matt....@gmail.com

unread,
Apr 21, 2014, 2:23:53 PM4/21/14
to exce...@googlegroups.com
Thank you for your prompt answer, however, the reason I am asking is because I don't see that specific example file in the mentioned folder. Could you please point me to it? I downloaded the whole code and somehow the file is not existent in the folder. Thanks

Govert van Drimmelen

unread,
Apr 21, 2014, 3:20:13 PM4/21/14
to exce...@googlegroups.com
Ah - OK, I guess it got added after the last release.

You can get the most recent check-in here: https://exceldna.codeplex.com/releases/view/119190

-Govert
Message has been deleted

matt....@gmail.com

unread,
Apr 21, 2014, 10:09:39 PM4/21/14
to exce...@googlegroups.com
Thank you for pointing me to the file. I implemented it by copying the code into my own C# dll. But I am getting a "#N/A" error when calling "WhatTimeIsIt()" from within Excel. Anything that I am missing out. I am sure I correctly compile and package the dna and such forth because I can access my UDFs within the same add-in from within Excel. 

Govert van Drimmelen

unread,
Apr 21, 2014, 10:39:46 PM4/21/14
to <exceldna@googlegroups.com>
Did you mark the class implementing the server as [ComVisible(true)]?
Did you get the namespace and class name right in the wrapper function where you call XlCall.RTD ?

-Govert


--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To post to this group, send email to exce...@googlegroups.com.
Visit this group at http://groups.google.com/group/exceldna.
For more options, visit https://groups.google.com/d/optout.

matt....@gmail.com

unread,
Apr 21, 2014, 11:09:33 PM4/21/14
to exce...@googlegroups.com
stupid me, I got the namespace wrong, works fine now. 
Reply all
Reply to author
Forward
0 new messages