Microsoft KB Archive/197032

= PRB: Choosing Quit in WFC Exception Dialog Box Shuts Down Host =

Article ID: 197032

Article Last Modified on 7/14/2004

-

APPLIES TO


 * Microsoft Visual J++ 6.0 Standard Edition
 * Microsoft Visual Basic 4.0 Standard Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 Enterprise Edition

-



This article was previously published under Q197032



SYMPTOMS
When an ActiveX control created with Windows Foundation Classes for Java (WFC) is placed in Visual Basic and throws an exception, the default WFC exception dialog box gives you the choice to either Continue, Quit, or See Details. If you click Quit, the entire process hosting the WFC control quits.

In an application hosted by the Visual J++ Integrated Development Environment (IDE), this is okay because the application is running in a different process than the IDE. However, in Visual Basic, the IDE and the application are in the same process until you actually make an .exe, so choosing Quit kills the entire Visual Basic IDE, along with any unsaved work.



RESOLUTION
There are two methods for resolving this issue. The first method is to never choose Quit in the WFC exception dialog box that appears when you receive an unhandled exception while hosting a WFC control in a Visual Basic application while running in the Visual Basic IDE. Instead, you should always choose Continue and then shut down the Visual Basic application from within the Visual Basic IDE.

The second method is to add an onThreadExceptionEventHandler to your WFC ActiveX control. This event handler is called instead of the default WFC exception handling routines and the default dialog box that contains the Quit option does not appear. Your WFC control, however, is responsible for handling exceptions, notifying the user, and shutting down as necessary.

Sample Code
The following sample code adds a very simple ThreadException Handler to a WFC ActiveX control: // ... Other WFC imports ...  import com.ms.wfc.app.*; // This creates the Application object.

public class Control1 extends UserControl {

// Define a Thread Exception Handler Delegate. private void threadException(Object sender, ThreadExceptionEvent e) { MessageBox.show("In Exception Handler"); }

public Control1 { // Add the Thread Exception Handler delegate. Application.addOnThreadException( new ThreadExceptionEventHandler        (this.threadException));

// Required for Visual J++ Form Designer support. initForm; }

// The rest of your WFC ActiveX control goes here... (c) Microsoft Corporation 1998, All Rights Reserved. Contributions by Steve Horne, Microsoft Corporation.



STATUS
This behavior is by design.

Keywords: kbbug kbprb kbwfc KB197032

-

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

© Microsoft Corporation. All rights reserved.