We have faced with issue during managed solution uninstall according to this tutorial.
Almost all basic steps were ok
- Installing holder solution (managed solution with only needed fields with modified unique name);
- Uninstalling old solution with redundant fields (managed);
- Installing new solution with correct unique name (with the same customization.xml content as in holder solution).
But, when we try to delete holder solution Invalid Argument exception occurred.
CrmDiagTool Trace Details:
Web Service Plug-in failed in SdkMessageProcessingStepId: {2A71496D-3F12-11DD-9BDE-0019B9312238}; EntityName: solution; Stage: 30; MessageName: Delete; AssemblyName: Microsoft.Crm.Extensibility.InternalOperationPlugin, Microsoft.Crm.ObjectModel, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35; ClassName: Microsoft.Crm.Extensibility.InternalOperationPlugin; Exception: Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Web.Services.Protocols.LogicalMethodInfo.Invoke(Object target, Object[] values)
at Microsoft.Crm.Extensibility.InternalOperationPlugin.Execute(IServiceProvider serviceProvider)
at Microsoft.Crm.Extensibility.V5PluginProxyStep.ExecuteInternal(PipelineExecutionContext context)
at Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.Execute(PipelineExecutionContext context)
Inner Exception: Microsoft.Crm.CrmArgumentException: Cannot add to the Sys Admin Profile
at Microsoft.Crm.ObjectModel.FieldPermissionServiceInternal'1.Create(IBusinessEntity entity, ExecutionContext context)
at Microsoft.Crm.ObjectModel.SolutionComponentUninstaller.Uninstall(ComponentTypeMapData componentTypeData, Guid componentObjectId, SolutionUninstallContext solutionUninstallContext)
at Microsoft.Crm.ObjectModel.UninstallHandler.CascadeUninstallToComponent(ComponentTypeMapData typeData, String[] conditionColumns, Object[] conditionValues, SolutionUninstallContext solutionUninstallContext)
at Microsoft.Crm.ObjectModel.FieldSecurityProfileUninstallHandler.CascadeUninstall(ComponentTypeMapData componentTypeData, Guid componentObjectId, SolutionUninstallContext solutionUninstallContext)
at Microsoft.Crm.ObjectModel.SolutionComponentUninstaller.Uninstall(ComponentTypeMapData componentTypeData, Guid componentObjectId, SolutionUninstallContext solutionUninstallContext)
at Microsoft.Crm.ObjectModel.TypeUninstallHandler.Uninstall(SolutionUninstallContext solutionUninstallContext)
at Microsoft.Crm.ObjectModel.SolutionUninstallService.Uninstall(ISolution solution, DynamicMetadataCache cache, ExecutionContext context)
at Microsoft.Crm.ObjectModel.SolutionServiceInternal'1.Delete(BusinessEntityMoniker moniker, ExecutionContext context)
Inner Exception: System.ArgumentException: Cannot add to the Sys Admin Profile
To make it clearer we have assumption that there is throw of CrmArgumentException with "Cannot add to the Sys Admin Profile" message somewhere in Microsoft.Crm.ObjectModel.FieldPermissionServiceInternal class in Create method.
What can be the cause of this issue and how can we resolve it?
There is only one Field Security Profile in system (System Administrator).
Thank you in advance!
P.S. Migration to CRM 2016 is not an option.
UPDATE
Here is problematic code of Create method in Microsoft.Crm.ObjectModel.FieldPermissionServiceInternal class:
public override BusinessEntityMoniker Create(IBusinessEntity entity, ExecutionContext context)
{
this.ValidateAttributeIsNonNull(entity, FieldPermissionServiceInternal<T>.ColumnNames.EntityName);
this.ValidateAttributeIsNonNull(entity, FieldPermissionServiceInternal<T>.ColumnNames.AttributeLogicalName);
this.ValidateAttributeIsNonNull(entity, FieldPermissionServiceInternal<T>.ColumnNames.FieldSecurityProfileId);
Guid profileId = (Guid) entity[FieldPermissionServiceInternal<T>.ColumnNames.FieldSecurityProfileId];
if (profileId == FieldLevelSecurityConstants.AdminProfileGuid)
throw new CrmArgumentException("Cannot add to the Sys Admin Profile");
...