[CRM 2011] Early bound types and plugins

Have you tried to use early bound types in plugins? After run crmsvcutil to generate the early bound types, you probably want to use them in your plugins. If the generated code is in the same assembly that the plugins, you won’t get any problem.


However, in a medium-big project, you may want to separate common functionality, as business processes or entity wrappers, from the rest.


How are you going to deploy that Common library? Either you can put it in the GAC or merge it with the Plugins assembly. However, as it is, you will get an “Unexpected error” the first time you try to use the IOrganizationService with early bound types inside of your plugins. Example:

public class PreCreateContact : BasePlugin
   protected override void ExecutePlugin(IOrganizationService service, ITracingService tracingService)
       Task newTask = new Task();
       newTask.Subject = "Testing";
       service.Create(newTask); //Here you will get the error


To avoid this exception, you should add the next line to AssemblyInfo.cs in your Plugin project

[assembly: Microsoft.Xrm.Sdk.Client.ProxyTypesAssemblyAttribute()]

About Ramon Tebar

Software Engineer specialised on Microsoft Technologies with experience in large projects for different industrial sectors as developer, consultant and architect. I enjoy designing and developing software applications, it is my job and one of my hobbies. I’m interested in design patterns, new technologies and best practices. Making those part of the ALM process is a great challenge. During the last years, I have specialised in Microsoft Dynamics CRM (now Dynamics 365). I customise and extend the platform to provide tailored solutions and integrations based on service-oriented architectures and messages queuing. Motivated by community events and contributor in blogs, technical books, open source projects and forums, I have been awarded Microsoft Most Valuable Professional (MVP) on Dynamics 365 (CRM) since 2012.

Posted on June 13, 2011, in CRM, CRM 2011 and tagged , . Bookmark the permalink. 1 Comment.

  1. It’s always great to read stuff from the master of coding …

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: