Could not load file or assembly ‘ABCD.Common, Version=188.8.131.52, Culture=neutral, PublicKeyToken=a6a250603368f7aa’ or one of its dependencies. The system cannot find the file specified.’
An error when try to run a workflow or a plugin in Dynamics CRM. This usually happens when we deploy a plugin or workflow activity however we don’t deploy or merge external referenced dlls which are needed.
In this example I will create an external project in addition to Workflow activity project and then reference that external project/dll in workflow activity project.
After deployment I got error below
This error is occuring as my Workflow project TestNotNeeded is expecting a dll from an other project Common project which exists in code however have not been deployed to CRM. One option would be drop that dll on app server if you have access to or merge it with TestNotNeeded dll.
In this case I will merge it using ILMerge tool
First this need to do is, install ILMerge tool using nuget in project TestNotNeeded
Next we need to go to properties of project > Build Events>Post-build event command line>Edit Post-Build…
Next need to edit Post-build event command line in visual studio and add script below (amend it accoridng to your requirement, path etc.)
$(SolutionDir)packages\ilmerge.2.14.1208\tools\ILMerge.exe /keyfile:$(SolutionDir)MyTest.Common\MyTest.Entities.snk /target:dll /copyattrs /out:$(TargetDir)$(TargetName)$(TargetExt) $(ProjectDir)$(IntermediateOutputPath)$(TargetName)$(TargetExt) $(SolutionDir)MyTest.TestNotNeeded\bin\Debug\MyTest.Common.dll
Complie project againa and deploy your workflow acitivty dll. You will get an error that ‘Plug-in assembly does not contain the required types or assembly content cannot be updated.’ and to fix this you will need unregister assembly and reregister again and/or remove it from exiting workflows
Once deployed and tested you will see it works now.
Above method can be used to merge any other external dlls.