I am writing a plugin for a client on a CRM Online trial tenant (so assume it has latest patches etc.) and have come across an error I’ve not seen before. Generally speaking I always use an extension method along the lines of the following, just for clarity of code really:
public static void AddOrUpdate(this Entity e, string propertyName, object value)
{
if (e.Attributes.Contains(propertyName))
{
e.Attributes[propertyName] = value;
}
else
{
e.Attributes.Add(propertyName, value);
}
}
Nothing hugely controversial there I think? Anyway for whatever reason if I include the class file as part of a plugin for this client, I get the following error thrown:
Unhandled Exception: System.ServiceModel.FaultException`1
System.TypeLoadException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #9A0442A7
[foo.bar.Plugins: foo.bar.Plugins.TrackActivity]
[6ed535ec-c7a8-e211-858f-3c4a92dbdc37: foo.bar.Plugins.TrackActivity: Create of task]
There is no trace included, which shows the plugin isn’t even executed (even if the first line of code is throwing an exception!).
I did a bit of digging and it seems that for this client/instance at least:
- If I include a static class file (public static class Foo
) with any method, I get this error, whether the class is actually used by code or not
- When the error is generated, the plugin itself is not executed (the exception occurs before any code)
Anyone seen anything like this before or have any insight into System.TypeLoadException
exceptions?