Troubleshooting Form Templates That Use the InfoPath 2003 Object Model At Design Time

The following sections describe common troubleshooting scenarios you may encounter while designing and debugging managed code form templates that use the InfoPath 2003-compatible object model provided by the Microsoft.Office.Interop.InfoPath.SemiTrust namespace.

If you attempt to debug or preview a managed-code project that contains code that invokes object model members that require full trust, InfoPath will display the error message "An unhandled security exception has occurred in the form's code" and the form will not open. To allow business logic in the form template to be debugged or previewed, you must set the security level to Full Trust and digitally sign the form template. For details on how to do this, see How to: Preview and Debug Managed Code Form Templates that Require Full Trust.

If you add an event handler to a field or group and later change the schema of the data source in the InfoPath Data Source task pane in a way that affects that field or group (for example, by renaming or moving it), a message will be displayed asking if you want to update the XPath expressions in your form's code. The XPath expressions referred to in this message are the values specified in the MatchPath parameter of the InfoPathEventHandlerAttribute attribute, which are used to associate the event handler with a field or group in your form's data source. No other XPath expressions in your code will be updated. The algorithm for updating the XPath expressions depends on a value being present in the MatchPath parameter of the InfoPathEventHandler attributes that are applied in your form code. If you manually deleted these values before responding to the prompt to update XPath expressions, InfoPath will not be able to update the XPath expressions automatically. For more information, see How to: Add an Event Handler Using the InfoPath 2003 Object Model.

The InfoPath 2003-compatible object model does not support calls on a separate thread. For example, the following code, which calls a function named LaunchOMFunction that calls members of the InfoPath object model, will not run.

Thread th = new Thread(new ThreadStart(LaunchOMFunction));
th.Start();

When necessary, there is a way to work around this limitation. For information, see Threading Support in InfoPath Projects Using the InfoPath 2003 Object Model.

If you open two or more InfoPath forms in editing mode, and then open Visual Studio and click Debug Process on the Tools menu, only one instance of INFOPATH.EXE is displayed in the Available Processes list of the Processes dialog box. This is by design. Only the top window of the INFOPATH.EXE process is displayed in the list. However, all InfoPath windows are running in the same process and are attached to the debugger.

If an InfoPath object model member contains an optional parameter, and you do not specify a value for that parameter, you must pass the Type.Missing field for that parameter instead. Failure to pass the Type.Missing field when an actual value is omitted will result in a build error. This is true for code written in both Visual Basic and Visual C#. For more information and examples see the "Passing Optional Parameters to InfoPath Object Model Members" section in the InfoPath 2003 Compatible Object Models topic.

Show: