title: "An unexpected error ocurred" CRM2015 OnPremise Plugins
body: <p>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: </p>
  
  <blockquote>
    <p>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.</p>
    
    <p>at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[]
    arguments, Signature sig, Boolean constructor)</p>
    
    <p>at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object
    obj, Object[] parameters, Object[] arguments)</p>
    
    <p>at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,
    BindingFlags invokeAttr, Binder binder, Object[] parameters,
    CultureInfo culture)</p>
    
    <p>at System.Web.Services.Protocols.LogicalMethodInfo.Invoke(Object
    target, Object[] values)</p>
    
    <p>at
    Microsoft.Crm.Extensibility.InternalOperationPlugin.Execute(IServiceProvider
    serviceProvider)</p>
    
    <p>at
    Microsoft.Crm.Extensibility.V5PluginProxyStep.ExecuteInternal(PipelineExecutionContext
    context)</p>
    
    <p>at
    Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.Execute(PipelineExecutionContext
    context)</p>
    
    <p>Inner Exception: System.Reflection.TargetInvocationException:
    Exception has been thrown by the target of an invocation.</p>
    
    <p>at System.RuntimeTypeHandle.CreateInstance(RuntimeType type,
    Boolean publicOnly, Boolean noCheck, Boolean&amp; canBeCached,
    RuntimeMethodHandleInternal&amp; ctor, Boolean&amp; bNeedSecurityCheck)</p>
    
    <p>at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly,
    Boolean skipCheckThis, Boolean fillCache, StackCrawlMark&amp; stackMark)</p>
    
    <p>at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly,
    Boolean skipCheckThis, Boolean fillCache, StackCrawlMark&amp; stackMark)</p>
    
    <p>at System.Activator.CreateInstance(Type type, Boolean nonPublic)</p>
    
    <p>at System.Activator.CreateInstance(Type type)</p>
    
    <p>at
    Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.InitializePlugin[T](IOrganizationContext
    context, StepDescription stepDescription, SecureConfigurationCache
    stepSecureConfigurationCache, Type type)</p>
    
    <p>at Microsoft.Crm.Extensibility.V5PluginProxyStep..ctor(Guid stepId,
    SecureConfigurationCache stepSecureConfigurationCache, CrmEventLog
    eventLog, IOrganizationContext context)</p>
    
    <p>at Microsoft.Crm.Extensibility.PluginStep..ctor(Guid stepId,
    SecureConfigurationCache stepSecureConfigurationCache, CrmEventLog
    eventLog, IOrganizationContext context)</p>
    
    <p>at
    Microsoft.Crm.Extensibility.PipelineStepFactory.CreateInstance(Guid
    stepId, IOrganizationContext context)</p>
    
    <p>at Microsoft.Crm.Caching.PipelineStepCacheLoader.LoadCacheData(Guid
    key, ExecutionContext context)</p>
    
    <p>at
    Microsoft.Crm.Caching.ObjectModelCacheLoader`2.LoadCacheData(TKey key,
    IOrganizationContext context)</p>
    
    <p><em>   at
    Microsoft.Crm.Caching.CrmMultiOrgCacheBase`2.CreateEntry(TKey key,
    IOrganizationContext context)</p>
    
    <p>at Microsoft.Crm.Caching.CrmSharedMultiOrgCache`2.LookupEntry(TKey
    key, IOrganizationContext context)</em></p>
    
    <p><em>   at
    Microsoft.Crm.Caching.MessageProcessorCacheLoader.GetCustomizationLevel(MessageProcessor
    mp, ExecutionContext context)</em></p>
    
    <p><em>   at
    Microsoft.Crm.Caching.MessageProcessorCacheLoader.LoadCacheData(MessageProcessorKey
    key, ExecutionContext context)</em>    at
    Microsoft.Crm.Caching.ObjectModelCacheLoader`2.LoadCacheData(TKey key,
    IOrganizationContext context)</p>
    
    <p>at Microsoft.Crm.Caching.CrmSharedMultiOrgCache`2.LookupEntry(TKey
    key, IOrganizationContext context)</p>
    
    <p>at
    Microsoft.Crm.Extensibility.InternalMessageDispatcher.TryGetMessageProcessor(MessageProcessorKey
    key, ExecutionContext context)</p>
    
    <p>at
    Microsoft.Crm.Extensibility.ExtensiblePlatformMessageDispatcher.IsPipelineDefined(MessageProcessorKey
    key, ExecutionContext context)</p>
    
    <p>at
    Microsoft.Crm.Extensibility.ExtensiblePlatformMessageDispatcher.CreateWithInvocationSource(BusinessEntity
    entity, Int32 invocationSource, ExecutionContext context)</p>
    
    <p>at
    Microsoft.Crm.BusinessEntities.BusinessProcessObject.Create(IBusinessEntity
    entity, ExecutionContext context)</p>
    
    <p>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.</p>
    
    <p>at SCM.CRM.Plugins.Plugin..ctor(Type childClassName)</p>
    
    <p>at SCM.CRM.Plugins.PLGServicioBase..ctor()</p>
  </blockquote>
  
  <p>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?</p>