This article was created in response to a support issue logged with K2. The content may include typographical errors and may be revised at any time without notice This article is not considered official documentation for K2 software and is provided “as is” with no warranties.

Issue

If you are developing a workflow using K2 for Visual Studio and include the following kinds of elements:


- References to custom .NET assemblies built for .NET 4.5.2

- The checkbox "Local copy" within the reference window is enabled 
- Data event, IPC event, Server event code consuming the custom .NET assemblies from GAC

Then on a developer machine, you can successfully deploy from Visual Studio and run the workflow with success. You can also package and deploy this package using "K2 Package and Deployment" on the same server.

However, if you try to deploy the same package using "K2 Package and Deployment" on a different development server, you will get an error when deploying the workflow. The error does not contain any detailed information and will only display the following:

"Deployment was unsuccessful due to an unknown error.":

System.Reflection.TargetInvocationException: The following errors occurred while compiling the process (with framework version 4.5.2):
Deployment was unsuccessful due to an unknown error. ---> System.Exception: The following errors occurred while compiling the process (with framework version 4.5.2):
Deployment was unsuccessful due to an unknown error.
at SourceCode.Runtime.Services.Workflow.IsolatedDeploymentController.HandleDeploymentResults(DeploymentResults results, String error)
at SourceCode.Runtime.Services.Workflow.IsolatedDeploymentController.DeployWorker(Object param)
--- End of inner exception stack trace ---
at SourceCode.Runtime.Services.Workflow.IsolatedDeploymentController.Deploy(String[] parts, String kprojDir, String kprojName, String kprxDir, String kprxName, String targetFramework, IEnumerable`1 refs)
at SourceCode.Runtime.Services.Workflow.IsolatedDeploymentController.IsolatedDeploy(Action`1 data, ComplexType ct, IEnumerable`1 refs, ISecurityManager securityManager, IServiceMarshalling serviceMarshalling, IEnvironment environment)
at SourceCode.Runtime.Services.Workflow.WorkflowDeploymentService.Deploy(IDeploymentContext context)
at SourceCode.Deployment.Runtime.ServerSession.AsyncDeploy()"

You know that the reason for the workflow failing to deploy is because of the custom reference assemblies, since if you remove them, it deploys successfully.

Symptoms

When deploying the same package using "K2 Package and Deployment" on a different development server, the error appears.

Troubleshooting Steps

As a workaround, you can "strong sign" your custom DLL assemblies, this should help with deploying in the future.

Follow the guidance on this link: https://docs.microsoft.com/en-us/dotnet/framework/app-domains/how-to-sign-an-assembly-with-a-strong-name

Please also make sure you have pre-deployed all the custom assemblies to the target deployment server, preferably in the GAC.