0

I have a C# RTDServer that works well in one instance of excel. It is defined as follows:

[Guid("1D50EF28-A1BE-4BE9-9214-46A48085ADFF")]
[ProgId("Acme.RtdServer")]
public class RTDServer : IRtdServer
{
   // IRtdServer members:
   // ...
}

When the server is "connected" excel calls

#region IRtdServer Members    
public int ServerStart(IRTDUpdateEvent CallbackObject)
{
    _callback = CallbackObject;
}

with a callback object which can thereafter be used to notify excel that updates are available to be collected:

_callback.UpdateNotify();

The problem is that if I have a second, third etc. instance of excel, ServerStart is never called, which means I cannot notify excel that new updates are ready. A MS KB article here suggests similar behavior for out-of-process RTDServers. My implementation is a threaded, in-process RTDServer.

I would like to be able to use the same server Acme.RtdServer across multiple instances. It must be possible since the Bloomberg Excel API seems to achieve it. Does anyone know how this can be achieved?

EDIT: The calls to RTD() is wrapped in a UDF:

public object ACME_UDF(string ItemID, string TopicName, bool OtherData = false)
{
    if (string.IsNullOrEmpty(ItemID) || string.IsNullOrEmpty(TopicName))
    return "...";

    try
    {
        return _xlApp.WorksheetFunction.RTD("acme.rtdserver", null, ItemID, TopicName, OtherData); 
    }
    catch (Exception)
    {
        return "Failed to retrieve [" + ItemID + "] with [" + TopicName + "]";
    }
}

thanks

Pat Mustard
  • 1,852
  • 9
  • 31
  • 58
  • There should be no interference between processes in loading the InProc COM server. Are you sure you have different instances of Excel (different processes in Task Manager) and not just different windows of the same process? – Govert Mar 05 '13 at 12:26
  • Yes, I can see both in the process explorer. I can't figure out how the additional process seems to know that ServerStart(...) has been called by the 1st one. – Pat Mustard Mar 05 '13 at 15:32
  • Could it be something to do with the GUID being registered and additional instances of excel being aware of this? – Pat Mustard Mar 05 '13 at 15:41
  • I have an RTD server that works fine in different instances. Your RTD server / Excel must be special. Is your COM object activated in the second instance? Have you tried with a really simple RTD server? – Govert Mar 05 '13 at 19:50
  • Thanks, Govert. I have tested a bare-bones rtdserver and it works with multiple instances. Must be something else. – Pat Mustard Mar 06 '13 at 03:06
  • There is something else I forgot to mention: The call to RTD() is wrapped in a UDF. When I manually put a call to just RTD(), server start is called in the second instance. – Pat Mustard Mar 07 '13 at 01:30
  • Do you have a problem with the wrapped RTD call when using your bare-bones RTD server? – Govert Mar 07 '13 at 14:18
  • The wrapped RTD() works in the first instance with no problems but not in additional instances. However, in additional instances, calling (unwrapped) RTD() operates normally and calls ServerStart() as expected. – Pat Mustard Mar 07 '13 at 15:11

1 Answers1

0

[Can't seem to add any comments. When I try it says "11 more to go..."] The version is 2010, 32-bit

Pat Mustard
  • 1,852
  • 9
  • 31
  • 58