Limit to RTD Server?

111 views
Skip to first unread message

Sprayer2708

unread,
Mar 25, 2025, 3:31:10 AM3/25/25
to Excel-DNA
Hi, I'm currently trying to figure out an issue with an Add-In which uses Excel DNA. Our AddIn can send and recieve market data to a server. We have created UDF which in the end call XlCall.Excel(XlCall.xlfRtd, RtdServer.ServerProgId,....). After that our RTD server is started with ServerStart(), if it didn't happen from an earlier call, and the data gets connected with ConnectData().

So far, so good. When we tested it, it all worked as expected. I should mention we are running Excel2019 32bit. After that, we sent it to our Project lead for further testing. He is running Office365 on 64bit. He built a somewhat bigger Excel workbook than we did and hitched upon a problem.

In his workbook, when he calls a UDF with the exact same parameters as he did previously again, nothing happens. I was able to reproduce this issue using his workbook and his server settings, which he set up in a way that data he sends from the addin will be sent back by the server under a different name.

One sheet as similar excel (original) formular in multiple rows, they look like =IF(boolExp;PUBLISH(service;instrument;fields1;values1);PUBLISH(service;instrument;fields2;values2)). PUBLISH here would be our UDF. boolExp resolves to TRUE. Now when I change a value of the values1 range, PUBLISH, ConnectData() and so forth are all called as expected. But when I change that value back, PUBLISH is called, but ConnectData() is never reached. I went through this with the Debugger and noticed IRtdServer.ConnectData() is also never reached. I went through the workbook to check wether PUBLISH is present anywhere else with the same set of parameters, but it is not.

Here's what's kicking it for me: I had sent our Project lead an older version of the addin, but there it worked for him. On that same version, the problem exists for me though. On the current version of our AddIn, I can get it to work as expected by changing the excel (adjusted) formula to =PUBLISH(service;instrument;IF(boolExp;fields1;fields2);IF(boolExp;values1;values2)). But this doesn't work on his end. When I create an entirely new workbook and in one sheet add just the header and a single row with that original formula, it doesn't work.

I have to add, that a single row also contains multiple calls to our UDF STREAM, the results of which constitute the values2 range, which should be ignored(?). But in the original formula, the PUBLISH with the field1 and values1 ranges still seems to get called when the values2 range gets updated.

Sprayer2708

unread,
Mar 25, 2025, 3:35:46 AM3/25/25
to Excel-DNA
So to my question, are there limits to Excel-DNA or Excel itself I am not aware of interfering here? Is there a solution I am not seeing? Do you need more information?

Govert van Drimmelen

unread,
Mar 25, 2025, 5:12:59 AM3/25/25
to exce...@googlegroups.com

The further arguments you pass to "XlCall.Excel(XlCall.xlfRtd, RtdServer.ServerProgId,....)” form an array of topic strings that identify an RTD topic.

If you call with the same topic strings, and the topic is already ‘alive’ you will get back the existing value for the topic, without your RTD server “ConnectData” being called. So to really understand what is going on, you should also check and log which “DisconnectData” calls are made, so that you can correlate the various calls for each topic (and for each array of topic strings). Your UDF might also have some data conversions before calling the xlfRtd function, causing different arguments to the UDF being called as the same strings to the xlfRtd call.

 

There have also been some RTD bugs related to the Disconnect in the past, though they are resolved in current versions. And further, there were some changes made to the Excel RTD implementation a few years ago (including fixing problems with array-returning RTD functions, and allowing ThreadSafe UDFs to call RTD).

If you are testing with a mix of versions, I would start by characterizing the behaviour with the current version first, then figuring out whether other versions you test with behave differently.

 

It’s hard to say much more without having a working example project to poke at.

 

-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 view this discussion visit https://groups.google.com/d/msgid/exceldna/58985cbe-ec5b-4d02-978d-8a150dc474edn%40googlegroups.com.

Sprayer2708

unread,
Mar 25, 2025, 5:21:13 AM3/25/25
to Excel-DNA
Right, I forgot to mention that DisconnectData is also not called with the original formula. I'll see if I can whip up the project in a way that shows what doesn't work without violating our company policy.

Sprayer2708

unread,
Apr 11, 2025, 8:02:39 AM4/11/25
to Excel-DNA
Update on this, if anyone finds this in the future:
Turns out Excel may convert functions into matrix functions when openening files created by another version of excel. Matrix Functions do weird stuff. Thanks to Govert for pointing this out to me.

Sidenote: I used to create multiple instances of RTD server by giving different GUIDs in place of server name in the xlCall(xlRTD....) method. Apparently, that wasn't how it was supposed to be used. The requirement which was the only reason for me to create multiple instances of RTD was removed, so I removed the GUID stuff I had.
In this circumstance, when you open a Workbook which was created with an older appversion (in which UDF called xlCall with a server name other than empty string or null), the initially present UDFs will not call your defined UDFs, but directly the RTD servers ConnectData. However, they still remember the server name, which causes the old excel functions to interact with a different rtd server instance than freshly created ones. To resolve, the functions need to be retriggered, for example by deleting the excel functions and reentering with ctrl+z.
Just leaving this here so the internet doesn't forget!
Reply all
Reply to author
Forward
0 new messages