[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

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.

Other advices/ideas:

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.

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