Использование внешних библиотек в моем плагине Dynamics / PowerApps - PullRequest
0 голосов
/ 04 апреля 2020

Я сделал очень простой плагин, используя мощные приложения cli.

pac plugin init

, затем добавил «Microsoft.Extensions.DependencyInjection», потому что я хотел использовать его для своего плагина. Желая сделать простой тест, если он будет работать.

  protected override void ExecuteCdsPlugin(ILocalPluginContext localPluginContext)
  {
        if (localPluginContext == null)
        {
            throw new ArgumentNullException("localPluginContext");
        }

        IPluginExecutionContext context = localPluginContext.PluginExecutionContext;

        var container = new ServiceCollection();
        localPluginContext.Trace("Hej form PLugin");
    }

Я использовал ILMerge для объединения библиотек вместе, но затем получил следующую ошибку от d365 при попытке импортировать мою сборку плагина.

Unhandled Exception: System.ServiceModel.FaultException

Unable to load plug-in assembly.


Server stack trace: 
   at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
   at Microsoft.Xrm.Tooling.Connector.CrmServiceClient.Update(Entity entity)
   at Xrm.Sdk.PluginRegistration.Helpers.RegistrationHelper.UpdateAssembly(CrmOrganization org, String pathToAssembly, CrmPluginAssembly assembly, PluginType[] type)
   at Xrm.Sdk.PluginRegistration.Forms.PluginRegistrationForm.btnRegister_Click(Object sender, EventArgs e)

Detail: 
<OrganizationServiceFault xmlns="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <ActivityId>03761df6-50f7-44d5-aea9-603e0ddbd4c4</ActivityId>
  <ErrorCode>-2147204719</ErrorCode>
  <ErrorDetails xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
    <KeyValuePairOfstringanyType>
      <a:key>ApiExceptionSourceKey</a:key>
      <a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">Plugin/Microsoft.Crm.ObjectModel.PluginAssemblyService</a:value>
    </KeyValuePairOfstringanyType>
    <KeyValuePairOfstringanyType>
      <a:key>ApiOriginalExceptionKey</a:key>
      <a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">Microsoft.Crm.CrmException: Unable to load plug-in assembly. ---&gt; Microsoft.Crm.CrmException: Unable to load plug-in assembly.
   at Microsoft.Crm.ObjectModel.PluginAssemblyServiceInternal`1.LoadCrmPluginAssemblyMetadata(IBusinessEntity pluginAssembly, ExecutionContext context, Boolean loadAllMetadata)
   at Microsoft.Crm.ObjectModel.PluginAssemblyServiceInternal`1.RetrieveAssemblyMetadata(IBusinessEntity pluginAssembly, ExecutionContext context, Boolean retrieveFromExisting, Boolean forSystemAssembly)
   at Microsoft.Crm.ObjectModel.PluginAssemblyServiceInternal`1.ValidateOperation(String operationName, IBusinessEntity entity, ExecutionContext context)
   at Microsoft.Crm.ObjectModel.SdkEntityServiceBase.UpdateInternal(IBusinessEntity entity, ExecutionContext context, Boolean verifyAction)
   at Microsoft.Crm.ObjectModel.PluginAssemblyServiceInternal`1.Update(IBusinessEntity entity, ExecutionContext context)
   --- End of inner exception stack trace ---
   at Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.Execute(PipelineExecutionContext context)
   at Microsoft.Crm.Extensibility.PipelineInstrumentationHelper.Execute(Boolean instrumentationEnabled, String stopwatchName, ExecuteWithInstrumentation action, PipelineExecutionContext context)
   at Microsoft.Crm.Extensibility.Pipeline.&lt;&gt;c__DisplayClass3_0.&lt;RunStep&gt;b__0()</a:value>
    </KeyValuePairOfstringanyType>
    <KeyValuePairOfstringanyType>
      <a:key>ApiStepKey</a:key>
      <a:value i:type="b:guid" xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/">a0cdbb1b-ea3e-db11-86a7-000a3a5473e8</a:value>
    </KeyValuePairOfstringanyType>
    <KeyValuePairOfstringanyType>
      <a:key>ApiDepthKey</a:key>
      <a:value i:type="b:int" xmlns:b="http://www.w3.org/2001/XMLSchema">1</a:value>
    </KeyValuePairOfstringanyType>
    <KeyValuePairOfstringanyType>
      <a:key>ApiActivityIdKey</a:key>
      <a:value i:type="b:guid" xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/">03761df6-50f7-44d5-aea9-603e0ddbd4c4</a:value>
    </KeyValuePairOfstringanyType>
    <KeyValuePairOfstringanyType>
      <a:key>ApiPluginSolutionNameKey</a:key>
      <a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">System</a:value>
    </KeyValuePairOfstringanyType>
    <KeyValuePairOfstringanyType>
      <a:key>ApiStepSolutionNameKey</a:key>
      <a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">System</a:value>
    </KeyValuePairOfstringanyType>
    <KeyValuePairOfstringanyType>
      <a:key>ApiExceptionCategory</a:key>
      <a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">SystemFailure</a:value>
    </KeyValuePairOfstringanyType>
    <KeyValuePairOfstringanyType>
      <a:key>ApiExceptionMesageName</a:key>
      <a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">UnableToLoadPluginAssembly</a:value>
    </KeyValuePairOfstringanyType>
    <KeyValuePairOfstringanyType>
      <a:key>ApiExceptionHttpStatusCode</a:key>
      <a:value i:type="b:int" xmlns:b="http://www.w3.org/2001/XMLSchema">500</a:value>
    </KeyValuePairOfstringanyType>
    <KeyValuePairOfstringanyType>
      <a:key>0</a:key>
      <a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">Failed to load plugin assembly with exception System.Runtime.InteropServices.COMException (0x80131130): Record not found on lookup. (Exception from HRESULT: 0x80131130)
   at Microsoft.Crm.IMetaDataImport.FindTypeDefByName(Char[] szTypeDef, IntPtr tkEnclosingClass, UInt32&amp; mdTypeDef)
   at Microsoft.Crm.CrmPluginAssemblyMetadata.ProcessTypeRef(UInt32 typeRef)
   at Microsoft.Crm.CrmPluginAssemblyMetadata.ProcessType(UInt32 token)
   at Microsoft.Crm.CrmPluginAssemblyMetadata.ProcessTypeDef(UInt32 typeDef)
   at Microsoft.Crm.CrmPluginAssemblyMetadata.ProcessType(UInt32 token)
   at Microsoft.Crm.CrmPluginAssemblyMetadata.LoadMetadata()
   at Microsoft.Crm.CrmPluginAssemblyMetadata.LoadMetadataFromAssemblyContent(Byte[] assemblyContents, Boolean loadAllMetadata)
   at Microsoft.Crm.CrmPluginAssemblyMetadata.LoadMetadataFromAssemblyContent(String content, Boolean loadAllMetadata)
   at Microsoft.Crm.ObjectModel.PluginAssemblyServiceInternal`1.LoadCrmPluginAssemblyMetadata(IBusinessEntity pluginAssembly, ExecutionContext context, Boolean loadAllMetadata). PluginInfo =&gt; Crm plugin assembly info : minor = 0, sourcetype = 0, description = , pluginassemblyid = 4fe48456-7588-4719-be66-046867ad491b, organizationid = f4a5f3e4-79f7-4173-96e6-1a48a20ad8f5, publickeytoken = 90C972DA50DF131B, authtype = 0, name = test, culture = neutral, major = 1, isolationmode = 2, version = 1.0.0.0, solutionid = fd140aae-4df4-11dd-bd17-0019b9312238, </a:value>
    </KeyValuePairOfstringanyType>
    <KeyValuePairOfstringanyType>
      <a:key>1</a:key>
      <a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">System.Runtime.InteropServices.COMException (0x80131130): Record not found on lookup. (Exception from HRESULT: 0x80131130)
   at Microsoft.Crm.IMetaDataImport.FindTypeDefByName(Char[] szTypeDef, IntPtr tkEnclosingClass, UInt32&amp; mdTypeDef)
   at Microsoft.Crm.CrmPluginAssemblyMetadata.ProcessTypeRef(UInt32 typeRef)
   at Microsoft.Crm.CrmPluginAssemblyMetadata.ProcessType(UInt32 token)
   at Microsoft.Crm.CrmPluginAssemblyMetadata.ProcessTypeDef(UInt32 typeDef)
   at Microsoft.Crm.CrmPluginAssemblyMetadata.ProcessType(UInt32 token)
   at Microsoft.Crm.CrmPluginAssemblyMetadata.LoadMetadata()
   at Microsoft.Crm.CrmPluginAssemblyMetadata.LoadMetadataFromAssemblyContent(Byte[] assemblyContents, Boolean loadAllMetadata)
   at Microsoft.Crm.CrmPluginAssemblyMetadata.LoadMetadataFromAssemblyContent(String content, Boolean loadAllMetadata)
   at Microsoft.Crm.ObjectModel.PluginAssemblyServiceInternal`1.LoadCrmPluginAssemblyMetadata(IBusinessEntity pluginAssembly, ExecutionContext context, Boolean loadAllMetadata)</a:value>
    </KeyValuePairOfstringanyType>
  </ErrorDetails>
  <HelpLink>http://go.microsoft.com/fwlink/?LinkID=398563&amp;error=Microsoft.Crm.CrmException%3a80044191&amp;client=platform</HelpLink>
  <Message>Unable to load plug-in assembly.</Message>
  <Timestamp>2020-04-04T13:15:04.9070444Z</Timestamp>
  <ExceptionRetriable>false</ExceptionRetriable>
  <ExceptionSource i:nil="true" />
  <InnerFault>
    <ActivityId>03761df6-50f7-44d5-aea9-603e0ddbd4c4</ActivityId>
    <ErrorCode>-2147204719</ErrorCode>
    <ErrorDetails xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
    <HelpLink i:nil="true" />
    <Message>Unable to load plug-in assembly.</Message>
    <Timestamp>2020-04-04T13:15:04.9070444Z</Timestamp>
    <ExceptionRetriable>false</ExceptionRetriable>
    <ExceptionSource i:nil="true" />
    <InnerFault i:nil="true" />
    <OriginalException i:nil="true" />
    <TraceText i:nil="true" />
  </InnerFault>
  <OriginalException i:nil="true" />
  <TraceText i:nil="true" />
</OrganizationServiceFault>

Можно ли использовать другие библиотеки DLL в плагинах или нужно просто избегать попыток исправить такие ошибки выше?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...