Handle Exceptions in Plug-Ins

[Applies to: Microsoft Dynamics CRM 2011]

For synchronous plug-ins, whether registered in the sandbox or not, the Microsoft Dynamics CRM platform handles exceptions passed back from a plug-in by displaying an error message in a dialog of the web application user interface. The exception message for asynchronous registered plug-ins is written to a System Job (AsyncOperation) record that can be viewed in the System Jobs area of the web application.

For synchronous plug-ins, you can optionally display a custom error message in the web application by having your plug-in throw an InvalidPluginExecutionException exception with the custom message string as the exception Message property value. If you throw InvalidPluginExecutionException and do not provide a custom message, a generic default message is displayed. It is recommended that plug-ins only pass an InvalidPluginExecutionException back to the platform.

If a synchronous plug-in returns an exception other than InvalidPluginExecutionException back to the platform, the error dialog is displayed to the user and the exception message (System.Exception.Message) with stack trace is also written to one of two places. For plug-ins not registered in the sandbox, the information is written to the Application event log on the server that runs the plug-in. The event log can be viewed by using the Event Viewer administrative tool. For plug-ins registered in the sandbox, the exception message and stack trace is written to the Microsoft Dynamics CRM platform trace. For more information about tracing, see the Logging and Tracing section of the Debug a Plug-In topic.

See Also

Microsoft Dynamics CRM 2011
Send comments about this topic to Microsoft.
© 2013 Microsoft Corporation. All rights reserved.

Community Additions