Microsoft KB Archive/922210

= The XDocumentBeforeClose event does not occur when you exit InfoPath 2007 without first closing a form =

Article ID: 922210

Article Last Modified on 2/7/2007

-

APPLIES TO


 * Microsoft Office InfoPath 2007

-





SYMPTOMS
Consider the following scenario:  You design a new Microsoft Visual C# Add-in project for Microsoft Office InfoPath 2007.  You use the following code example to change the OnConnection event method. This code example also changes the applicationObject definition to Private ApplicationClass applicationObject;. applicationObject = (ApplicationClass)application; addInInstance = addInInst;

((ApplicationEventsClass)applicationObject.Events).XDocumentBeforeClose += new         _ApplicationEvents_XDocumentBeforeCloseEventHandler(Connect_XDocumentBeforeClose);   You add a method definition that resembles the following code example. void Connect_XDocumentBeforeClose(_XDocument pDocument, ref bool pfCancel) {               System.Windows.Forms.MessageBox.Show(&quot;Connect_XDocumentBeforeClose&quot;); }  You build and install the new add-in. You open the form in InfoPath 2007. You exit InfoPath 2007 without first closing the form.

In this scenario, the XDocumentBeforeClose event does not occur.

<div class="cause_section">

CAUSE
This behavior occurs because the XDocumentBeforeClose event may prevent InfoPath 2007 to shut down by returning &quot;fCancel=true&quot;. However, if the XDocumentBeforeClose event is called, the event is ignored, and the returned value may confuse some third-party developers. Therefore, use the Application::Quit command if you must perform cleanup tasks related to opened documents.

<div class="status_section">

STATUS
This behavior is by design.

Keywords: kbtshoot kbprb KB922210

-

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

© Microsoft Corporation. All rights reserved.