我们在CRM 2015 OnPremise中遇到了一个关于插件的小型完全随机问题。当我们进行上传时,随机且没有太大意义(至少根据分析所有代码都没有)插件会给我们带来以下异常:
OrganizationId中的Web Service插件失败: fb2630bc-8dc1-e411-80be-bae05bad392c; SdkMessageProcessingStepId: d2713f4e-51b7-e411-80b8-527d00dcf108; EntityName:new_serviciobase; 阶段:30; MessageName:创建;的AssemblyName: Microsoft.Crm.Extensibility.InternalOperationPlugin, Microsoft.Crm.ObjectModel,Version = 7.0.0.0,Culture = neutral, 公钥= 31bf3856ad364e35;班级名称: Microsoft.Crm.Extensibility.InternalOperationPlugin;例外: 未处理的异常:System.Reflection.TargetInvocationException: 调用目标引发了异常。
at System.RuntimeMethodHandle.InvokeMethod(Object target,Object [] arguments,Signature sig,Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,Object []参数,Object []参数)
在System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr,Binder binder,Object []参数, 文化信息文化)
at System.Web.Services.Protocols.LogicalMethodInfo.Invoke(Object target,Object [] values)
在 Microsoft.Crm.Extensibility.InternalOperationPlugin.Execute(的IServiceProvider 的ServiceProvider)
在 Microsoft.Crm.Extensibility.V5PluginProxyStep.ExecuteInternal(PipelineExecutionContext 上下文中)
在 Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.Execute(PipelineExecutionContext 上下文中)
内部异常:System.Reflection.TargetInvocationException: 调用目标引发了异常。
在System.RuntimeTypeHandle.CreateInstance(RuntimeType类型, Boolean publicOnly,Boolean noCheck,Boolean& canBeCached, RuntimeMethodHandleInternal&安培; ctor,布尔& 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)
在System.Activator.CreateInstance(Type type,Boolean nonPublic)
在System.Activator.CreateInstance(类型类型)
在 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)
在 Microsoft.Crm.Extensibility.PipelineStepFactory.CreateInstance(GUID stepId,IOrganizationContext context)
at Microsoft.Crm.Caching.PipelineStepCacheLoader.LoadCacheData(Guid) key,ExecutionContext context)
在 Microsoft.Crm.Caching.ObjectModelCacheLoader`2.LoadCacheData(TKey key, IOrganizationContext context)
at Microsoft.Crm.Caching.CrmMultiOrgCacheBase`2.CreateEntry(TKey键, IOrganizationContext context)
在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)
在 Microsoft.Crm.Extensibility.InternalMessageDispatcher.TryGetMessageProcessor(MessageProcessorKey key,ExecutionContext context)
在 Microsoft.Crm.Extensibility.ExtensiblePlatformMessageDispatcher.IsPipelineDefined(MessageProcessorKey key,ExecutionContext context)
在 Microsoft.Crm.Extensibility.ExtensiblePlatformMessageDispatcher.CreateWithInvocationSource(的BusinessEntity entity,Int32 invocationSource,ExecutionContext context)
在 Microsoft.Crm.BusinessEntities.BusinessProcessObject.Create(IBusinessEntity entity,ExecutionContext context)
内部异常:System.IO.FileLoadException:无法加载文件或 assembly'SCM.CRM.Core,Version = 1.0.0.0,Culture = neutral, PublicKeyToken = 369abd01f82b8d9d'或其依赖项之一。访问是 拒绝。
at SCM.CRM.Plugins.Plugin..ctor(Type ChildClassName)
at SCM.CRM.Plugins.PLGServicioBase..ctor()
它带来了一点点头痛,因为我们不了解发生了什么,只是有时会失败,有时候不会......我们有一个自定义库注册的插件(磁盘)" SCM.Core.dll&#34 ;说自己无法访问...任何想法?
答案 0 :(得分:1)
正如@Sxntk所说,如果在注册插件程序集时使用沙盒模式隔离模式,则需要确保将所有插件与ilmerge合并。
如果您的隔离模式为“无”,请确保程序集位于GAC中或放在服务器上CRM安装目录的bin \ assembly文件夹中。
希望这有帮助。
答案 1 :(得分:0)
我是Alexis的同事,现在我们有更多细节,感谢crmdiagtool:
System.IO.FileLoadException:Microsoft Dynamics CRM遇到错误。管理员或支持的参考编号:#ED0C936C:System.IO.FileLoadException:无法加载文件或程序集' SCM.CRM.Core,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = 369abd01f82b8d9d'或其中一个依赖项。访问被拒绝。 文件名:' SCM.CRM.Core,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = 369abd01f82b8d9d'
答案 2 :(得分:0)
您可以执行以下操作:
<Target Name="AfterResolveReferences">
<ItemGroup>
<EmbeddedResource Include="@(ReferenceCopyLocalPaths)" Condition="'%(ReferenceCopyLocalPaths.Extension)' == '.dll'">
<LogicalName>%(ReferenceCopyLocalPaths.DestinationSubDirectory)%(ReferenceCopyLocalPaths.Filename)%(ReferenceCopyLocalPaths.Extension)</LogicalName>
</EmbeddedResource>
</ItemGroup>
</Target>
&#13;
将此方法添加到插件类:
private static Assembly OnResolveAssembly(object sender, ResolveEventArgs args)
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
AssemblyName assemblyName = new AssemblyName(args.Name);
string path = assemblyName.Name + ".dll";
if (assemblyName.CultureInfo.Equals(CultureInfo.InvariantCulture) == false)
{
path = String.Format(@"{0}\{1}", assemblyName.CultureInfo, path);
}
using (Stream stream = executingAssembly.GetManifestResourceStream(path))
{
if (stream == null)
return null;
byte[] assemblyRawBytes = new byte[stream.Length];
stream.Read(assemblyRawBytes, 0, assemblyRawBytes.Length);
return Assembly.Load(assemblyRawBytes);
}
}
将以下构造函数添加到插件类:
static [Constructor name]()
{
AppDomain.CurrentDomain.AssemblyResolve += OnResolveAssembly;
}
重建并注册您的插件
执行此操作时,本地复制到bin文件夹的所有引用程序集都将打包到主dll中。缺点是你最终可能有一个巨大的dll,你无法将其注册为插件。
希望这有帮助, 干杯