2

I'm adding DDE for my app (C# 3.5) and sometimes when I open thousands (6000) of DDE channels it works, and sometimes, especially during debugging and excel crashes, it only gives me some of the items.

I suspect that the DDE channels are still "active" in Windows and when I try to open more I reach the DDE channels limit (10,000) and then not all have data.

Is there a way to "clean" the DDE engine in Windows, so I'll start fresh? or is restarting Windows the only solution?

Tomer Pintel
  • 1,567
  • 1
  • 13
  • 14
  • 1
    DDE is the goto of interop. Watch out, that raptor will eat you any moment now. – Hans Passant Jan 10 '11 at 12:37
  • 1
    In 2011, your question reads like "I suspect that the memory control blocks are still 'active' in DOS and when I try to open more I reach the 64KB limit" – Tim Robinson Jan 13 '11 at 23:30
  • If you are using C# 3.5 you should not be using DDE, since it is deprecated. I bet you could do what you want using OLE. Lookup COM-Interop for Exel for more information. See also this answer: http://stackoverflow.com/questions/2442586/dynamic-data-exchange-dde-still-relevant/2442598#2442598 – frast Jan 10 '11 at 08:59
  • For "deprecated", substitute "obsolete since 15 years ago" – Tim Robinson Jan 13 '11 at 23:29
  • 4
    Come on people, do you think I WANT to add DDE support? Sometimes we have a little thing called backward compatibility... – Tomer Pintel Jan 16 '11 at 11:08

1 Answers1

0

If you're using the open source NDde (http://ndde.codeplex.com/) then you can use the DdeClient class which implements the IDisposable pattern. Then use the client inside a using block. This effectively creates a finally block which should close the connection if an exception is thrown. E.g.,

using (DdeClient client = new DdeClient(DDE_SERVER_NAME, dataField))
{
    client.Connect();

    string data = client.Request("xyz", DDE_TIMEOUT);
}

However, I've experienced the same thing though with data not being consistently returned but I not opening thousands of connections so it may be a different issue.

User
  • 62,498
  • 72
  • 186
  • 247