Export (0) Print
Expand All

Create and Deploy Plug-ins Using the Developer Toolkit

[Applies to: Microsoft Dynamics CRM 2011]

Your solution must contain a plug-in project before you can create a plug-in. For more information, see Create a New Developer Toolkit Project.

In This Topic

Plugins Project

The Plugins project contains a base class named Plugin that implements the Microsoft.Xrm.Sdk.IPlugin interface. All plug-in classes generated through the Create Plug-in option of the CRM Explorer will derive from this class. This class simplifies some of the common code that is required by many plug-ins, including the following:

  • Obtaining execution context from the service provider.

  • Obtaining the tracing service from the service provider.

  • Instantiating the Organization Service proxy.

Additionally, the validation method verifies several typical plug-in events and provides a pattern for the developer to extend.

Initially, the derived class’ implementation calls the base class’ implementation before continuing with its own, more specific implementation.

After validating that the plug-in should execute, the base class calls up to the Execute method of the derived class, passing through the execution context and Organization Service proxy.

For more information about how to work with plug-ins, see Write Plug-Ins to Extend Business Processes.

Create and Deploy a Plug-in

Use the following procedure to create and deploy a plug-in.

To Create and Deploy a Plug-in

  1. In CRM Explorer, locate the entity that you want to create the plug-in for. Right-click the entity and then select Create Plug-in.

    • If the current project already has an existing plug-in assembly registered, you can also use the Add Plugin shortcut menu option on the existing plug-in assembly and then select the entity you want it to apply to.

  2. The Create Plug-in dialog box appears with the fields in the following table.


    Field Description


    The plug-in library project in your Visual Studio solution.


    A recommended class name based on the selected pipeline stage and message.

    Primary Entity

    The entity that must be processed by the execution pipeline for the plug-in to execute.

    Secondary Entity

    Some messages require a secondary entity. See the documentation on the specific message for more information.


    The message that must be processed by the Microsoft Dynamics CRM execution pipeline for the plug-in to execute.

    Filtering Attributes

    A list of entity attributes that cause the plug-in to execute when it is changed. A value of null causes the plug-in to execute if any of the attributes change. When you specify a message that supports filtering attributes, for example Update, an ellipsis (…) button is displayed that lets you select attributes from a list.

    Run in Context

    Specify the system account that owns any data changes the plug-in makes. The Calling User is the logged on user who initiated the message to be processed. For more information, see Impersonation in Plug-Ins.

    Execution Order

    Specifies the order, also known as rank, that plug-ins are executed in a pipeline stage. Plug-ins registered by using an order value of 1 are executed first, followed by plug-ins registered by using an order of 2, and so on. However, if there is more than one plug-in in a stage with the same order value, the plug-in with the earliest compilation date is called first.

    Pipeline Stage

    Specifies when you want the plug-in to execute: before (Pre) or after (Post) the core operation that processes the message. For more information, see Event Execution Pipeline.


    Specify where you want the plug-in deployed: on the server, on Microsoft Dynamics CRM for Outlook with Offline Access, or both.

    Execution Mode

    For plug-ins registered to execute in a post stage, specify if you want them to execute immediately (synchronous) or queued to execute later (asynchronous). For post operations, specifying asynchronous execution gives you improved system performance compared to synchronous execution.


    A description of the step. Typically, you can describe the purpose of the step for other developers or administrators who might run the registration tool at a later date.

    Unsecure Configuration

    If you have written a constructor for the plug-in that takes one or two string arguments, any string values that you specify in these fields are passed to the plug-in constructor at run-time. For more information, see Write a Plug-In.

    Secure Configuration

    Pre Image Alias

    A pre-image is a snapshot of the entity’s attributes before the core operation. The entity alias value that you specify is used by your plug-in code as the key into the image collection.


    The list of attributes to be include in the pre-image.

    Post Image Alias

    A post-image is a snapshot of the entity’s attribute after the core operation. The entity alias value that you specify is used by your plug-in code as the key into the image collection.


    The list of attributes to be include in the post-image.

  3. In the Create Plugin dialog box, click OK to generate the plug-in code. This action also updates the RegisterFile.crmregister in the CRM Package project to store the plug-in registration information.

  4. Open the class that is generated and locate this comment // TODO: Implement your custom Plug-in business logic. Add your custom plug-in business logic to that method.

  5. In the Properties of the plug-in project, on the Signing tab, select the Sign the assembly check box and set the strong name key file of your choice.At a minimum, you must specify a new key file name. Do not protect your key file by using a password.

  6. Right-click the CRM Package project and select Deploy.

    This builds the dependent projects and deploys the plug-in to the Microsoft Dynamics CRM server. Subsequent changes to the plug-in are pushed to the server during the build and deploy process.

You may get the error: Error registering plug-ins and/or workflows. Public Assembly must have public key after you have signed the assembly as described in step 5, when the solution contains a workflow assembly project that is not signed. All plug-in and workflow projects in the solution must be signed.

Add a Step to a Plug-in

You can only add steps to a plug-in included in the current project. In the CRM Explorer plug-in assemblies included in the current project will have a different icon as shown in the following table.


Plugin Icon Description
Plug-in Assembly in Solution

This plug-in assembly is part of the current solution

Plug-in Assembly not in solution

This plug-in assembly is registered in the organization but is not part of the current solution.

To Add a Step to a Plugin

  1. Right-click a plug-in that is part of a plug-in assembly that is included in the current solution and select Add Step.

  2. In the Create Plug-in dialog box, configure your step. For more information, see Create and Deploy a Plug-in about the options available.

See Also

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

Community Additions

© 2015 Microsoft