Hi everybody,
I'am developing a feature in D365 that allows the creation of plugins dynamically in an Assembly selected by administrator.
However i'am getting the following error : "Plug-in assembly does not contain the required types or assembly content cannot be updated".
For this example iam using the assembly called: "Dynamics365.Plugins".
This is my code:
var pluginCreate = new PluginType()
{
PluginAssemblyId = new EntityReference(PluginAssembly.EntityLogicalName,new Guid(assemblyId)),
TypeName = "Dynamics365.Plugins.Testing",
FriendlyName = "(APPROVAL) " + approvalTarget.noesis_ContextEntity + " " + namePluginStep,
Name = "(APPROVAL)." + approvalTarget.noesis_ContextEntity + "." + namePluginStep,
Description = "Plugin Registered Dynamically",
};
TracingService.Trace($"PluginAssemblyId : {pluginCreate.PluginAssemblyId}");
TracingService.Trace($"TypeName : {pluginCreate.TypeName}");
TracingService.Trace($"FriendlyName : {pluginCreate.FriendlyName}");
TracingService.Trace($"Name : {pluginCreate.Name}");
TracingService.Trace($"Description : {pluginCreate.Description}");
string pluginId;
try
{
pluginId = BusinessContext.Create(pluginCreate.ToEntity<Entity>()).ToString();
pluginStep.noesis_PluginId = pluginId;
}
catch (Exception e)
{
TracingService.Trace($"Error Message : {e.Message}");
throw new InvalidPluginExecutionException($"Could not create Plugin.\n\n");
}
This is my trace:
PluginStep ID: 5c08b5dd-f491-e911-a964-000d3a441cb0
Name: PreCreate
Approval Target ID : ede6525d-7690-e911-a964-000d3a441cb0
New Step Mode : Microsoft.Xrm.Sdk.OptionSetValue
New Step Rank : 1
New Step Stage : Microsoft.Xrm.Sdk.OptionSetValue
New Step DeleteAsync : False
New Step Name : PreCreate
New Step Filtering Attributes :
Assembly Id: e7cfcfb6-dad6-4eaf-9a51-c15b8822f1c5
PluginAssemblyId : Microsoft.Xrm.Sdk.EntityReference
TypeName : Dynamics365.Plugins.Testing
FriendlyName : (APPROVAL) opportunity PreCreate
Name : (APPROVAL).opportunity.PreCreate
Description : Plugin Registered Dynamically
Error Message : Plug-in assembly does not contain the required types or assembly content cannot be updated.
Hope you can help.
Thanks