Import solution with PowerShell is not activating SDK-steps

Today I deployed a solution with SDK-steps with the following PowerShell (intro to CRM and PowerShell can be found here):

if (-Not (Get-Module -Name Microsoft.Xrm.Data.Powershell)) { 
     Import-Module Microsoft.Xrm.Data.Powershell 
}

$zipLocation = 'C:\Users\x.y\Downloads'
$timeoutInSeconds = 600

$crmOrg = Get-CrmConnection -InteractiveMode
Set-CrmConnectionTimeout -TimeoutInSeconds:$timeoutInSeconds -conn:$crmOrg

Import-CrmSolutionAsync -SolutionFilePath:$zipLocation'\SdkSteps_Managed.zip' -OverwriteUnManagedCustomizations:$true -conn:$crmOrg -MaxWaitTimeInSeconds:$timeoutInSeconds -BlockUntilImportComplete:$true

Problem: After deploying the solution most of the SDK-steps were disabled.

Solution: Adding the following Import-CrmSolutionAsync-parameter solved the issue: 

-ActivateWorkflows:$true

So this paramteres triggers not only the activation of workflows it activates also the SDK-steps.


Supported .NET Framework Dynamics 365 (4.6.1 not supported!)

Problem: After migrating a Dynamics CRM environment from 2016 OnPrem to Dynamics 365 Online I was getting the following error message every time a plugin or a custom-workflow-activity was triggered:

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: 
Unexpected exception from plug-in (Execute): <Plugin.Message>: System.MissingMethodException: Method not found: '!!0[] System.Array.Empty()'.Detail:
<OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
  <ActivityId>6e625317-1f6a-46ff-8883-afaa96cb51ef</ActivityId>
  <ErrorCode>-2147220956</ErrorCode>
  <ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
  <Message>Unexpected exception from plug-in (Execute): <Plugin.Message>: System.MissingMethodException: Method not found: '!!0[] System.Array.Empty()'.</Message>
  <Timestamp>2017-08-22T08:18:06.9730831Z</Timestamp>
  <ExceptionRetriable>false</ExceptionRetriable>
  <ExceptionSource i:nil="true" />
  <InnerFault i:nil="true" />
  <OriginalException i:nil="true" />
  <TraceText>

Solution: After analyzing the problem and having a look at MSDN, I found out that the plugins CWAs were compiled with .NET-Framework 4.6.1 but only 4.5.2 is supported. After changing it back to 4.5.2, compiling and deploying everything worked well.


Error deleting a custom entity – Generic SQL error

Problem: Last week I a had to clean up a crm-system. So I had to delete a lot of fields and also entities. Deleting a custom entity caused the famous error “Generic SQL error.” After enablig the trace on the crm-server I got some more details:

>Crm Exception: Message: Generic SQL error., ErrorCode: -2147204784, InnerException: System.Data.SqlClient.SqlException (0x80131904): The DELETE statement conflicted with the SAME TABLE REFERENCE constraint "solutioncomponent_parent_solutioncomponent". The conflict occurred in database "ORG_MSCRM", table "dbo.SolutionComponentBase", column 'RootSolutionComponentId'.

Solution: After some googling and try outs, i realized that other solutions were still containing the entity. After removing the entity of all solutions (there were two more) I was able to delete the custom entity.