For 2 weeks we have been experiencing a small totally random issue with plugins in CRM 2015 OnPremise. When we make an upload, randomly and without much sense (at least according to analyze all code does not) plugins are throwing us the following exception:
The Web Service plug-in failed in OrganizationId: fb2630bc-8dc1-e411-80be-bae05bad392c; SdkMessageProcessingStepId: d2713f4e-51b7-e411-80b8-527d00dcf108; EntityName: new_serviciobase; Stage: 30; MessageName: Create; 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: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.InitializePlugin[T](IOrganizationContext context, StepDescription stepDescription, SecureConfigurationCache stepSecureConfigurationCache, Type type)
at Microsoft.Crm.Extensibility.V5PluginProxyStep..ctor(Guid stepId, SecureConfigurationCache stepSecureConfigurationCache, CrmEventLog eventLog, IOrganizationContext context)
at Microsoft.Crm.Extensibility.PluginStep..ctor(Guid stepId, SecureConfigurationCache stepSecureConfigurationCache, CrmEventLog eventLog, IOrganizationContext context)
at Microsoft.Crm.Extensibility.PipelineStepFactory.CreateInstance(Guid stepId, IOrganizationContext context)
at Microsoft.Crm.Caching.PipelineStepCacheLoader.LoadCacheData(Guid key, ExecutionContext context)
at Microsoft.Crm.Caching.ObjectModelCacheLoader`2.LoadCacheData(TKey key, IOrganizationContext context)
at Microsoft.Crm.Caching.CrmMultiOrgCacheBase`2.CreateEntry(TKey key, IOrganizationContext context)
at Microsoft.Crm.Caching.CrmSharedMultiOrgCache`2.LookupEntry(TKey key, IOrganizationContext context)
at Microsoft.Crm.Caching.MessageProcessorCacheLoader.GetCustomizationLevel(MessageProcessor mp, ExecutionContext context)
at Microsoft.Crm.Caching.MessageProcessorCacheLoader.LoadCacheData(MessageProcessorKey key, ExecutionContext context) at Microsoft.Crm.Caching.ObjectModelCacheLoader`2.LoadCacheData(TKey key, IOrganizationContext context)
at Microsoft.Crm.Caching.CrmSharedMultiOrgCache`2.LookupEntry(TKey key, IOrganizationContext context)
at Microsoft.Crm.Extensibility.InternalMessageDispatcher.TryGetMessageProcessor(MessageProcessorKey key, ExecutionContext context)
at Microsoft.Crm.Extensibility.ExtensiblePlatformMessageDispatcher.IsPipelineDefined(MessageProcessorKey key, ExecutionContext context)
at Microsoft.Crm.Extensibility.ExtensiblePlatformMessageDispatcher.CreateWithInvocationSource(BusinessEntity entity, Int32 invocationSource, ExecutionContext context)
at Microsoft.Crm.BusinessEntities.BusinessProcessObject.Create(IBusinessEntity entity, ExecutionContext context)
Inner Exception: System.IO.FileLoadException: Could not load file or assembly ‘SCM.CRM.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=369abd01f82b8d9d’ or one of its dependencies. Access is denied.
at SCM.CRM.Plugins.Plugin..ctor(Type childClassName)
at SCM.CRM.Plugins.PLGServicioBase..ctor()
It brings a little headache because we don't understand what happened, just that sometimes fails and sometimes not ... we have a custom library registered plugins (disk) "SCM.Core.dll" to which says itself unable to access ... Any ideas?
As @Sxntk said, you need to make sure you merge any plugins with ilmerge if you are using Sandbox mode isolation mode when registering the plugin assembly.
If you have an isolation mode of 'none', make sure the assembly is in the GAC or placed in the bin\assembly folder in the CRM installation directory on the server.
Hopefully this helps.