This project has moved. For the latest updates, please go here.

Initial values for RTD servers


This topic: 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.


Charlie81 wrote Apr 19, 2011 at 3: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 9: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 11:53 AM

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.