Writing a simple plugin to avoid attachments in Dynamics CRM Online, I have seen weird exceptions messages.
Note: Using Dynamics CRM 2011 Developer Toolkit from CRM 2011 SDK
Find all the code of this example and the CRM solution here
Initially, this is the code of the plugin linked to “annotation” in the Create and Update events (shown just the execute method):
Now, let’s try to attach a new file:
In this case, where an unknown error will happen, I could expect a message similar to this:
Notice I would be able to retrieve traces and see more information.
However, instead of that message, I am getting this other weird error without any trace or useful information: “The specified domain does not exist or cannot be contacted. An unexpected error occurred from ISV code”
To improve this message, I have had to add a try-catch, encapsulate that unexpected exception and throw an InvalidPluginExecutionException:
And now I get the next message:
As you can see, this message is a bit more friendly, but it is not yet the usual desired message we would like seeing with traces, something like this:
Exception messages in attachments for the annotation entity seem to behave differently compare to what we have seen in other entities. Use InvalidPluginExecutionException correctly to guarantee the best result.
If you are using CRM 2011 Developer Toolkit, Plugins inherit from Plugin class. You can improve the error handling in this base class and customise the traces and error logs in the way you better want.
One thought on “[CRM Online] Avoid attachments using a plugin and weird exception messages: The specified domain does not exist or cannot be contacted. An unexpected error occurred from ISV code”
I am attaching an Excel FIle and code is working fine when I run it via Plugin Registration Proilfer/Debug Mode.
But When I am running it without Debug; I am getting this error