Microsoft KB Archive/95462

= DDE Conversation Can Cause Error Message: DDE Channel Locked =

Article ID: 95462

Article Last Modified on 12/12/2003

-

APPLIES TO


 * Microsoft Visual Basic 2.0 Standard Edition
 * Microsoft Visual Basic 3.0 Professional Edition
 * Microsoft Visual Basic 2.0 Professional Edition
 * Microsoft Visual Basic 3.0 Professional Edition
 * Microsoft Visual Basic 1.0 Standard Edition

-



This article was previously published under Q95462



SUMMARY
The error message &quot;DDE channel locked&quot; indicates that an attempt is being made to open a DDE conversation between two objects that are already engaged in a conversation. However, usually the error message occurs in a Visual Basic application as a result of a non-Visual Basic DDE Server application failing to post or send a DDE message Visual Basic is expecting.

The best overall solution is to alter the DDE server application so that it correctly sends the appropriate DDE messages.

Both &quot;DDE channel locked&quot; and &quot;Timeout while waiting for DDE response&quot; are errors that can be trapped in Visual Basic, so you can work around the problem by performing the following steps:

  Turn on error trapping. For example: On Local Error GoTo DDEerrhand:  In your error handling routine, trap error #284 (&quot;DDE channel locked&quot;) and set the LinkTimeout property to 1. This triggers the error message &quot;Timeout while waiting for DDE response&quot; much quicker.  Also, in your error handling routine trap error #286 (&quot;Timeout while waiting for DDE response&quot;), reset the LinkTimeout value, re-establish the link, and execute a RESUME statement, as in this example: DDEerrhand: Select Case Err Case 284: OldLinkMode = Text1.LinkMode OldTimeout = Text1.LinkTimeout Text1.LinkTimeout = 1 Resume Case 286: Text1.LinkTimeout = OldTimeout Text1.LinkMode = 0 Text1.LinkMode = OldLinkMode Resume End Select 



MORE INFORMATION
The DDE conversation guidelines set by the Windows Software Development Kit (SDK) require that Visual Basic sometimes wait for an expected DDE message. If that message is never correctly sent or posted to Visual Basic, the following scenario is likely to occur, leading to the error message &quot;DDE channel locked&quot;:


 * 1) At some point between when Visual Basic established the conversation and the conversation terminated, the DDE server application fails to post or send a message that Visual Basic is expecting as a normal part of the DDE termination procedure.
 * 2) At this point, Visual Basic is in a PeekMessage loop waiting for a message from the server indicating that the server application has also terminated the DDE conversation. Because Visual Basic is yielding the CPU inside the loop, the Visual Basic code continues to execute and the DDE conversation appears to have terminated normally from the server side.
 * 3) Because Visual Basic is still waiting for the expected DDE message from the server application, the DDE channel is still open. Any attempt to reopen the channel (such as setting the LinkMode property for the control performing the DDE) results in a &quot;DDE channel locked&quot; error.

If no further DDE actions are attempted, you will receive a &quot;Timeout while waiting for DDE response&quot; error message. The timeout will occur after a number of milliseconds equal to the communicating control's LinkTimeout property.

Additional query words: 2.00 3.00 errmsg

Keywords: KB95462

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.