Welcome to MSDN Blogs Sign in | Join | Help

Creating a customized Plug-in Template for Microsoft Dynamics CRM 4.0

Today we welcome MVP Bill Ryan from CustomerEffective as our guest blogger.

In its basic form, CRM 4.0 Plugin development is straightforward, however it has many monotonous elements. This walkthrough on writing Plugins illustrates many of the repetitive tasks that plugin development entails.  Among them are:

  • Creation of a new Class Library Project
  • Renaming of the default class (class1.cs or class1.vb to Plugin name)
  • Adding references to the Microsoft.Crm.Sdk & Microsoft.Crm.SdkTypeProxy libraries
  • Aliasing those libraries
  • Making the class inherit from the IPlugin interface
  • Adding the methods for that interface (or letting VS do it for you)

Most of these items are pretty simple to do, but it is monotonous and you have to remember to do it each time.  However most non-trivial plugins require some sort of configuration information.  Because plugins are dynamic link libraries hosted by CRM (and typically stored in the database), you can't use Settings.config,app.config or web.config files like you would in most other projects.  If you need this functionality, you need to roll your own solution. 

Fortunately, when you register each step for your Plugin, the PluginRegistration tool gives you two sections, one for an unsecured configuration and one for Secure Configuration.  But unless you write code to do something with this information, simply storing it will provide no benefit. (Mitch Milam has an excellent introduction to this).  To take advantage of configuration information, you need to add a new constructor to your plugin and then write code to read the settings.

You can just copy and paste his code if you'd like, but in all likelihood you'll probably want to write something specifically suited to your needs. Normally this would be something you'd just create in a library and attach as a reference to your project. However because of the plugin registration process, you'll typically want to work with as few dll's as possible (assemblies which reside in the Global Assembly Cache are an exception to this because you don't need to do anything special to use them).

Anyway, I found myself copying and pasting the same  class over and over into each plugin I wrote and it was something that got old quickly. Additionally, when ever developers come on board who aren't familiar with Plugin development, they will typically get stuck making the same mistakes you made when you first started writing plugins, something which can cost a lot of time and frustration.

Read more for Bill's solution...

Cheers,

MVP Bill Ryan

Published Tuesday, December 09, 2008 8:34 AM by crmblog

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# My blog on Dynamics CRM Plug-ins made MSDN

Tuesday, December 09, 2008 7:29 PM by My blog on Dynamics CRM Plug-ins made MSDN

# My post on Plugin Development for Dynamics CRM made MSDN

Today it's even on the front page . If you're interested here it is

# Reading for 2008-12-10

The economy outside is frightful, but our machines are so delightful... It’s Time To Completely

Wednesday, December 10, 2008 9:11 AM by jakew

# Blogging Dynamics

MVP Bill Ryan put together an extensive post for the Dynamics.CRM team blog on "Creating a customized

Thursday, January 22, 2009 5:02 AM by The Microsoft MVP Award Program Blog

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker