2
Vote

Initial values for RTD servers

description

This topic: http://groups.google.com/group/exceldna/browse_thread/thread/ad6163ef47ace53d?hl=en_US in the Google group describes a problem with the RTD server support. The last value of an RTD topic that Excel caches is not available when the sheet is subsequently opened, perhaps due to the RTD registration mechanism.

comments

Charlie81 wrote Apr 19, 2011 at 4:02 AM

I suspect this might be because Excel-DNA creates a random GUID for the RTD server wrapper (correct me if I'm wrong here). Thus when opening a saved spreadsheet, Excel doesn't consider any of the cached RTD values to be relevant because functions are now pointing to an RTD server with a different GUID.

Perhaps it is better to make the GUID static, by checking if the IRtdServer already has a GUID attribute, and if so use that rather than generating one randomly each time (i.e. that way this behaviour could be optional).

govert wrote Apr 21, 2011 at 10:08 AM

Apparently the issue is the ProgId, rather than the Guid. Currently I generate the ProgId from the Guid - so that multiple instances of the 'same' RTD server can run in different add-ins. I'm planning to revisit the registration to address this issue for the next release.

govert wrote May 2, 2011 at 12:53 PM

There is a way to implement the preservation of saved RTD values in the latest version of Excel-DNA (from Change Set 65931). You need to make two changes:
  1. RTD servers can now be persistently registered (if the class implementing IRtdServer has both ProgId and Guid attributes). To register the add-in as a COM server, either call Regsvr32 .xll from a command line or installation tool, or call the Excel-DNA method ComServer.DllRegisterServer() from your AutoOpen. This will write the required registry entries pointing to the .xll, and allows your RTD server to be instantiated directly from a cell formula using =RTD(...).
  2. Update your wrapper UDFs. Instead of calling the Excel-DNA wrapper XlCall.RTD(...), call the Excel API version directly as object myResult = XlCall.Excel(XlCall.xlfRtd("My.ProgId", null, Topic1....)). This ensures that Exccel-DNA does not wrap your RTD call with the just-in-time volatile registration which disables the preserve values option.