注册插件/工作流DLL时出错“在指定的程序集中找不到插件类型”

时间:2013-12-24 18:30:24

标签: dynamics-crm-2011 dynamics-crm

我正在尝试更新CRM 2011 On Prem中的插件,并且插件注册工具正在返回此警告:

<OrganizationServiceFault xmlns="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <ErrorCode>-2147204720</ErrorCode>
  <ErrorDetails xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
  <Message>Plugin type could not be found in the specified assembly.</Message>
  <Timestamp>2013-12-24T18:26:45.3112774Z</Timestamp>
  <InnerFault>
    <ErrorCode>-2147204720</ErrorCode>
    <ErrorDetails xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
    <Message>Plugin type could not be found in the specified assembly.</Message>
    <Timestamp>2013-12-24T18:26:45.3112774Z</Timestamp>
    <InnerFault i:nil="true" />
    <TraceText i:nil="true" />
  </InnerFault>
  <TraceText i:nil="true" />
</OrganizationServiceFault>

有没有办法确定在指定程序集中找不到的插件类型是什么?

修改

反编译了microsoft dll。看起来我可以编写一个程序,给定两个dll,它会查找一个dll中的所有插件类型,并尝试将它们加载到另一个dll中。通过一些正确的错误处理,我将能够找出缺少的类型。

internal Type GetPluginTypeType(PluginAssembly parentAssembly, PluginType typeEntity)
{
  int num = (int) ((BusinessEntity) parentAssembly).get_Item("sourcetype");
  Assembly assembly;
  if (num == 0)
  {
    if (((BusinessEntity) parentAssembly).IsAttributeNull("content"))
      throw new CrmException("Assembly content should not be null or empty.", -2147204719);
    assembly = PluginAssemblyFactory.LoadAssembly(Convert.FromBase64String((string) ((BusinessEntity) parentAssembly).get_Item("content")));
  }
  else if (num == 1)
    assembly = PluginAssemblyFactory.LoadAssembly((string) ((BusinessEntity) parentAssembly).get_Item("path"));
  else if (num == 2)
    assembly = Assembly.Load(PluginAssemblyFactory.FormatAssemblyName((string) ((BusinessEntity) parentAssembly).get_Item("name"), new Version((string) ((BusinessEntity) parentAssembly).get_Item("version")), (string) ((BusinessEntity) parentAssembly).get_Item("culture"), (string) ((BusinessEntity) parentAssembly).get_Item("publickeytoken"), CacheSolutionHelper.GetCustomizationLevel((IBusinessEntity) parentAssembly) == 0));
  else
    throw new CrmException(string.Format((IFormatProvider) CultureInfo.InvariantCulture, "Unknown source type {0}.", new object[1]
    {
      (object) num
    }), -2147200995);
  if (assembly == (Assembly) null)
    throw new CrmException("Assembly could not be loaded.", -2147204719);
  Type type = assembly.GetType((string) ((BusinessEntity) typeEntity).get_Item("typename"));
  if (type == (Type) null)
    throw new CrmException("Plugin type could not be found in the specified assembly.", -2147204720);
  else
    return type;
}

1 个答案:

答案 0 :(得分:0)

我发现确定缺少哪一个的唯一方法是将“损坏的”插件程序集导入到沙盒环境中,您可以在其中查看导入的内容。然后检查两者之间是否有任何不同。有时您会发现您重命名了某些内容并且没有注意到。

除了检查GUID之外,这是非常困难的。