May i now the Difference between mscrm 4.0 and mscrm 2011 plug in creation

Answered May i now the Difference between mscrm 4.0 and mscrm 2011 plug in creation

  • Wednesday, May 02, 2012 1:56 PM
     
     

    Hi,

    May i now the Difference between mscrm 4.0 and mscrm 2011 plug in creation.

    Thanks,

    Toushu

All Replies

  • Wednesday, May 02, 2012 7:56 PM
     
     Answered
  • Wednesday, May 02, 2012 9:04 PM
     
     Answered Has Code


    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)

    I hope this helps. If my response answered your question, please mark the response as an answer and also vote as helpful.
    Mubasher Sharif
    Check out my about.me profile!
    http://mubashersharif.blogspot.com
    Linked-In Profile
    Follow me on Twitter!

  • Thursday, May 03, 2012 4:21 PM
     
     

    Hi Sharif,

    Thanks for your help.

    Regards

    Toushu


    Thanks, Toushu