Trace and Debug Plug-in in CRM 4

One fundamental point in CRM are the plug-ins. With this extension mechanism, we can add any business logic over our CRM solution. However, test and debug it is usually harder, since this assembly will be integrated in the server. Here are shown several options to drive this problem:

  • DevErrors in web.config: This configuration setting indicates what kind of error will be showed to the end user. By default, it will be a generic error without any information. If we enable this setting, we’ll get a more useful error page.

How to modify the Web.config file to show more detailed error messages in Microsoft CRM


  • Enable trace generated by CRM platform. From the register. In this article you can find the keys that you need to update:

How to enable tracing in Microsoft Dynamics CRM

To manage these traces easily, we have several tools:

  • Trace File Viewer: a extension for the Stunnware Tool to visualize easier the traces files generated by the platform

Stunnware Tools for Microsoft Dynamics CRM 4.0 – Trace File Viewer (free extension)

IMPORTANT NOTE: This trace are enabled for all the organisation and all users, so the performance of our system will be affected considerably. Remember to disable when you finish.

  • Custom Traces from inside of our plug-ins: without doubts, this is the cooler options, since we could even test live environment. The idea is create a trace entity in CRM which can be accessed like another entity. So, you can check the traces by web interface, outlook, web services, …. A very good example of implementation for this idea can be found in the framework of David Jack, which is described in his great book CRM as a Rapid Development Platform. You can read more and download the code from this site: In addition, in this framework he’s also developed another cool windows application tool β€œPlug-in Test Harness” to test a plug-in simulating that it has been registered in CRM, but without really need it.

Finally, we could debug our code step by step using Visual Studio:

  1. Copy the .pdb file, which is together with our generated dll in Debug folder, to C:\Program Files\Microsoft Dynamics CRM Server\Server\bin\assembly
  2. In Visual Studio, we go to Debug->Attach to Process
  3. Selected "w3wp.exe":

Leave a Reply

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

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

Facebook photo

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

Connecting to %s