5

As the title states, I'm looking for a way to tell the difference between an error caused by my code or basic CRM functionality and an error thrown by any custom plugin that may be installed on the clients system.

Something we continuously fall victim to is our clients custom third party plugins that either they created in house or bought from another ISV. They register it on a CRM entity we touch or even on one of our own entities in the most recent case. We try to do something, the plugin tries to do its thing and fails. In the most recent example, the plugin wasn't encoding a ' correctly after we put it into CRM. The plugin throws an error and CRM throws it back to us.

How can I tell that the plugin is the culprit without wasting hours investigating? So far I've only seen one company make it easy to tell by throwing the plugins stack trace as the error message.

EDITS FOR CLARITY:

  • I'm looking for a programmatic solution to cut down on the time it takes to identify the issue is a custom plugin and not our code interacting with their CRM from Azure.
  • I am attempting to enhance our error logging/handling to be smart enough to tell the difference.
  • Even if our code works 100% but triggers a synchronous plugin to fire and that plugin fails, we get an exception from CRM.
  • Everything we do is programmatic via the SDK.
Justin williams
  • 574
  • 1
  • 8
  • 26
  • So is this a failure that happens when your plugin attempts to perform some action which causes another plugin to fail, which then causes your plugin to fail? Or is it a failure that happens with a plugin before your plugin fires? – Daryl Apr 15 '13 at 14:10
  • We are technically not a 'plugin' We have an app that runs in Azure that interacts with a customers CRM system. The error happens in the customers plugin which filters down back to us even if we accomplished what we were trying to do we still get back an error. – Justin williams Apr 15 '13 at 14:13
  • So you're interacting with it using the SDK? – Daryl Apr 15 '13 at 14:16
  • Really the answer is to have the plugins throw better exceptions, but that obviously relies on the plugin provider to sort that for you. Otherwise, not sure I see much of a way round it other than a suite of integration tests that you can run to pinpoint the problem + coupled with Daryl's approach below. – glosrob Apr 15 '13 at 22:14
  • I was afraid of that but was hoping someone smarter than I had found something I hadn't. Daryl's approach can't be used. I can't take it upon myself to disable a customers plugins whenever an error happens. – Justin williams Apr 16 '13 at 15:12

4 Answers4

2

The only thing that comes to mind is to enable CRM tracing. The link below should explain how to do this in Microsoft Dynamics CRM.

http://support.microsoft.com/kb/907490

code4life
  • 15,655
  • 7
  • 50
  • 82
  • 1
    Sorry, I should have mentioned above. I'm looking for a programmatic solution that can be automated and part of our error logging. Having the customer go through and turn on tracing is part of the hours of investigation I'm trying to cut down on. – Justin williams Apr 15 '13 at 14:14
1

When there is an exception caused by a plugin as this picture: enter image description here

you can download the log file, inside you can easily find which plugin caused the exception, check for example this log:

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: StupidPluginDetail: 
// ... other details
[StupidPlugin: StupidPlugin.ExamplePlugin]
[bda9ad85-c4a5-e211-bc00-78e7d162ee67: StupidPlugin.ExamplePlugin: Create of orderclose]
</TraceText>
</OrganizationServiceFault>
Guido Preite
  • 14,905
  • 4
  • 36
  • 65
1

Have a look at Detail.TraceText property of exception returned by service. I haven't managed to get full stack trace, but it returned some info indicating where things went wrong:

Mario.CRM.TestOrg.Plugins: Mario.CRM.TestOrg.Plugins.ContactPreUpdate

[5ee31a9e-3558-e211-adeb-00155d014401: Mario.CRM.TestOrg.Plugins.ContactPreUpdate: Update of contact]

Sample code snippet

try
{
  //create service proxy and call service
}
catch (Exception ex)
{
  Console.WriteLine(((System.ServiceModel.FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault>)(ex)).Detail.TraceText);
}
MarioZG
  • 2,087
  • 11
  • 19
0

This wouldn't be recommended for use in a production environment, but would be extremely beneficial for a testing environment. Whenever a CRUD operation fails using the SDK, you could programmatically disable all plugins, and attempt the same operation. If it succeeds, enable the plugins one at a time until it fails. Then you'd be able to determine which plugin it is that is causing the issue, or whether it is not a plugin at all.

Daryl
  • 18,592
  • 9
  • 78
  • 145