共用方式為


Handle exceptions in plug-ins

 

Applies To: Dynamics CRM 2013

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 which 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 error dialog of 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 in the error dialog. 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

Plug-in development
Pass data between plug-ins
Write a plug-in
Debug a plug-In
Handle exceptions in your code