Export (0) Print
Expand All

Upgrade Plug-ins and Custom Workflow Activities

[Applies to: Microsoft Dynamics CRM 2011]

Microsoft Dynamics CRM provides legacy support for running Microsoft Dynamics CRM 4.0 plug-ins and custom workflow activities. You can leave your plug-ins and activities as they are and they will work. However, if you want to build your code using the latest SDK and add support for features new to Microsoft Dynamics CRM 2011, you will need to upgrade your code. Note that Microsoft Dynamics CRM Online does not support custom workflow activities.

One of the first steps in upgrading your code to support Microsoft Dynamics CRM 2011 is to simply compile the code. You will need to remove references in your Microsoft Visual Studio project to old SDK assemblies and add references to the Microsoft.Crm.Sdk.Proxy.dll and Microsoft.Xrm.Sdk.dll assemblies. If your code uses early-bound types instead of DynamicEntity, you also need to generate an early-bound types file using the CrmSvcUtil program and add that generated types file to your project. A non-customized early-bound types file named MyOrganizationCrmSdkTypes is included in the SDK download in the SampleCode\CS\HelperCode and SampleCode\VB\HelperCode folders to get you started a little quicker. However, if your organization has custom or customized entities, you should generate a new early-bound types file.

In This Topic

Plug-ins

After attempting to compile your code, you will see where the SDK API has changed. The following sub-topics describe some of these changes.

IPlugin Interface

The IPlugin interface has changed. The Execute method has a new signature, and you get references to the execution context and organization service using different code. For more information, see Write a Plug-In and the sample plug-ins in the SDK download.

Execution Context

There are some changes to the IPluginExecutionContext class. Specifically, the CallerOrigin property has been removed and replaced by the IsExecutingOffline and IsOfflinePlayback properties. Also, you can now directly determine if your plug-in is executing in the database transaction by examining the IsInTransaction property.

Early-bound Types

If you are using early-bound types like account, contact, and so on in your plug-in code you need to change those class names slightly. The new names are Account, Contact, and so on. These types are defined in the early-bound types file that is generated by the CrmSvcUtil program.

Exceptions

Your plug-in should check for a fault exception FaultException<OrganizationServiceFault> that can be returned from the Windows Communication Foundation (WCF) channel. For more information, see the SDK sample code for other exceptions that can occur.

Messages

Some messages have been deleted and new messages added. For example, the AssociateRequest message replaces the AssociateEntitiesRequest message. For more information, see the table in the Message-entity support for plug-ins.xlsx file in the Tools folder of the SDK download for a list of message and entity combinations that support plug-ins.

Enhancements

Finally, consider enhancing your code by making use of new features in this release of Microsoft Dynamics CRM. For example, add support for running your plug-in in the sandbox (isolation mode) so you can deploy it to Microsoft Dynamics CRM Online!

Plug-in Assembly Restrictions

The following restrictions now apply to plug-in assemblies.

  • All assemblies must be signed or delay signed.

  • The PluginAssembly records must be unique on Name+Culture+Major+Minor+PublicKeyToken.

  • The PluginType records must be unique on TypeName+PluginAssemblyId.

  • Registration of 32-bit assemblies is only supported on 32-bit clients. Trying to register a 32-bit assembly on a 64-bit server results in a registration error.

Custom Workflow Activities

The older .NET Framework 3.5 custom workflow activities for Microsoft Dynamics CRM 4.0 will continue to work with workflows in Microsoft Dynamics CRM 2011. However, you cannot use these activities with dialogs because only Microsoft .NET Framework 4 custom activities are supported for dialogs. The following sub-topics list the changes for the custom workflow activities in Microsoft Dynamics CRM 2011. For an example of a custom workflow activity before and after upgrade, see Upgrading a CRM 4.0 Custom Workflow Activity to CRM 2011.

.NET 4 Support and Allied Changes

Processes in Microsoft Dynamics CRM 2011 now support Microsoft .NET Framework 4. As a result, to create custom workflow activities in Microsoft Dynamics CRM 2011:

  • Create a class that inherits from the CodeActivity workflow base class. The CodeActivity base class is available in the System.Activities namespace

  • The Execute method in your custom activities must take a parameter of CodeActivityContext type instead of the ActivityExecutionContext type.

  • Define input, output, and default parameters using the new Microsoft Dynamics CRM process classes. Moreover, you no longer have to define dependency properties while defining the input and output parameters to indicate that the process is dependent on the value.

For more information about these points, see Create a Custom Workflow Activity.

Name and Group Name (WorkflowActivityGroupName) for a Custom Workflow Activity

The name and group name of a custom workflow activity is now specified while registering the custom workflow activity assembly instead of at the compilation time. These are the values that will appear in the Process designer in the Microsoft Dynamics CRM Web application to identify your custom activity. For more information, see Specify the Name and Group Name for a Custom Workflow Activity.

Namespace for Microsoft Dynamics CRM Process Classes

Use the Microsoft.Xrm.Sdk.Workflow namespace instead of the Microsoft.Crm.Workflow namespace to create custom activities. You can use the Microsoft.Xrm.Sdk.Worklow namespace by adding a reference to the Microsoft.Xrm.Sdk.Workflow.dll file in your project. For example, to specify the input parameters in your custom activity, you now have to use the InputAttribute class instead of the CrmInputAttribute class.

Namespace for Microsoft Dynamics CRM Process Activities

Use the Microsoft.Xrm.Sdk.Workflow.Activities namespace instead of the Microsoft.Crm.Workflow.Activities namespace to create custom activities. You can use the Microsoft.Xrm.Sdk.Workflow.Activities namespace by adding a reference to the Microsoft.Xrm.Sdk.Workflow.dll file in your project.

Early-bound Types

Same as mentioned earlier for plug-ins in this topic.

Messages

Same as mentioned earlier in the Messages section for plug-ins.

Custom Workflow Assembly Restrictions

Same as mentioned earlier in the Plug-in Assembly Restrictions section. Additionally, custom workflow activities must be unique on Name+WorkflowActivityGroupName.

Post Upgrade Issues and Resolution

In Microsoft Dynamics CRM 4.0 it was possible to specify incorrect values for plug-in images, entity attributes, and step registration attributes during plug-in registration. This is because the Plug-in Registration tool and Microsoft Dynamics CRM 4.0 employed limited validation for plug-in registration. Invalid images and attributes were ignored by the Microsoft Dynamics CRM 4.0 system at run-time.

In Microsoft Dynamics CRM 2011, plug-in registration images and attributes are fully validated. This can lead to issues after a system upgrade when exporting plug-ins and steps to a solution. The plug-in registration configuration in the exported solution will not be correct. Importing such a solution will fail.

The resolution to this problem is to correct the plug-in registration configuration after the Microsoft Dynamics CRM 4.0 upgrade has completed but before exporting plug-in assemblies and steps as a solution. Use the Plug-in Registration tool provided in the Microsoft Dynamics CRM 2011 SDK to make the necessary registration changes.

The following are known plug-in registration configuration issues.

  1. Specifying an invalid attribute in an image or step. For example, the attribute name is not spelled correctly or the attribute does not exist in Microsoft Dynamics CRM 2011.

  2. Registering a pre-image for a CreateRequest or a post-image for a DeleteRequest.

  3. Specifying an incorrect deployment type. For example, registering a plug-in to execute on an assign of an account for deployment on Microsoft Dynamics CRM for Microsoft Office Outlook with Offline Access when that message and entity combination is supported only on the server.

See Also

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

Community Additions

ADD
Show:
© 2014 Microsoft