FIX: GPF/UAE When Closing DDE Application from the Task List

Last reviewed: October 30, 1997
Article ID: Q94166
2.00 WINDOWS kbinterop kbprg kbbuglist

The information in this article applies to:

- Microsoft Visual Basic programming system for Windows, version 2.0

SYMPTOMS =======+

A General Protection (GP) fault or an Unrecoverable Application Error (UAE) occurs under the following conditions:

- A Visual Basic application is actively communicating via a Dynamic

  Data Exchange (DDE) link
- The Visual Basic application is acting as the destination (or client) in
  the DDE conversation.
- You close the application by choosing End Task from the Windows task list
  while the DDE link is still active.

WORKAROUND

To work around the problem, ensure that the DDE conversion terminates before the Visual Basic application terminates by setting the LinkMode property to zero in an event other than the Unload or QueryUnload events for Form1. To do this, you need to enable a timer within the Form_Unload (or Form_QueryUnload) event. Within the Timer event, set the LinkMode property to zero to terminate the DDE conversation.

STATUS

Microsoft has confirmed this to be a problem in Microsoft Visual Basic version 2.0 for Windows. This problem was corrected in Microsoft Visual Basic version 3.0 for Windows.

MORE INFORMATION

The following steps reproduce this problem:

  1. Run Microsoft Excel. Sheet1 is created by default.

  2. From the Edit menu, choose Copy to copy cell R1C1 (row 1, column 1) to the clipboard.

  3. Run Visual Basic, or if Visual Basic is already running, choose New Project from the File menu (ALT, F, N). Form1 is created by default.

  4. Add a Text box (Text1) to Form1.

  5. With the Text box highlighted, choose Paste Link from the Edit menu (ALT, E, L).

  6. Type some text in R1C1 in Excel. You should see the result in Text1 of Visual Basic.

  7. Make an executable program in Visual Basic by choosing Make .EXE File from the File menu. Name the executable file P1.EXE.

  8. From the Windows Program Manager or Windows File Manager, run P1.EXE.

  9. Press CTRL+ESC to bring up the Task List.

  10. Select Project1 from the list of programs running.

  11. From the Task List, choose the End Task button.

At this point, a GP fault or UAE occurs at address 0011:026A.

To summarize, you can avoid the entire problem by inserting the following steps (4a - 4c) after step 4 shown above. Then redo steps 1 through 11.

4a. Add a timer control (Timer1) to Form1 4b. Add the following code to the Form_Unload event of Form1:

   Sub Form_Unload (Cancel As Integer)

      'Cause the DDE conversation to terminate from within the Timer
      'event
         Timer1.Interval = 1
         Timer1.Enabled = True

      'Allow the timer event to occur
         DoEvents

      End Sub

4c. Add the following code to the Timer1_Timer event:

   Sub Timer1_Timer ()
      'Terminate the DDE conversation
         Text1.LinkMode = 0

      'Timer has served its purpose, so disable it.
         Timer1.Enabled = False
   End Sub


Additional reference words: buglist2.00 fixlist3.00 1.00 2.00 3.00 GPF
KBCategory: kbinterop kbprg kbbuglist
KBSubcategory: IAPDDE EnvtRun
Solution Type : kbfix


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: October 30, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.