The changes between CRM 2011 and CRM 4 with regards to plugins are not that much. Like a lot of the changes it involves using the XRM dll rather than CRM dll. In many ways it seems Microsoft were busying changing others in CRM 2011 to worry about the plugins.
Although they have added in WCF services rather than Web services (don’t panic they do still work)
There are a few subtle differences and we now use Entity rather than Dynamicentity. This is a nice improvement and will make coding easier.
It’s always good to know what has changed and today I saw this concise list of the major differences between plugins in CRM 2011 and CRM 4. I would also like to say this blog is excellent from a CRM developers point of view, the articles are always interesting and have excellent code examples. I have added to my netvibes so I know when he adds any more posts.
5 syntax changes in Dynamics CRM 2011 plugins
There are number of changes between Dynamics CRM 2011 SDK and CRM 4 SDK. Let’s take a look at what has changed between plugins.
| 1. The IPlugin now resides in Microsoft.Xrm.Sdk namespace instead of Microsoft.Crm.Sdk | |
| public class ClassName : Microsoft.Crm.Sdk.IPlugin public class ClassName : Microsoft.Xrm.Sdk.IPlugin |
|
| 2. The Execute method signature of the IPlugin interface has changed, it now expects an IServiceProvider instead of the IPluginExecutionContext. | |
public void Execute(IPluginExecutionContext context) public void Execute(IServiceProvider serviceProvider) |
|
| 3. To get a reference to the IPluginExecutionContext you now need to call the GetService method of the IServiceProvider interface. | |
public void Execute(IPluginExecutionContext context)
Microsoft.Xrm.Sdk.IPluginExecutionContext context =(Microsoft.Xrm.Sdk.IPluginExecutionContext)
serviceProvider.GetService(typeof(Microsoft.Xrm.Sdk.IPluginExecutionContext));
|
|
| 4. ICrmService has been changed to IOrganizationService. | |
ICrmService sdk = context.CreateCrmService(true); IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory)); IOrganizationService sdk = factory.CreateOrganizationService(context.UserId); |
|
| 5. DynamicEntity has been changed to Entity. · Properties property of DynamicEntity no longer exists · Getting and Setting values no longer use *Property classes, eg: no more KeyProperty, StringProperty…etc, simply do int value = (int)entity[“schema_name”]; |
|
if (context.InputParameters.Properties.Contains("Target") &&
context.InputParameters.Properties["Target"] is DynamicEntity)
if (context.InputParameters.Contains("Target") &&
context.InputParameters["Target"] is Entity)
|
|



Jim
November 17, 2011
Just found your blog. It’s interesting that you complain about your posts being copied and also copy other’s posts in this way.
Hosk
November 17, 2011
What I was complaining about was someone copying posts and not referencing. Any material I put on the blog is always linked to the original source and I almost always suggest the reader reads the original. I don’t claim material that I haven’t written.
I think there is value in linking to other excellent CRM posts and adding some insight from myself.
my blog was being copied and not referenced.