Skip to main content
Solved

WorkflowManagementServer throw error Method not found: System.AppDomainManager in .NET6 K2 Five 5.3


I have .Net Framework 4.8 console app which opens connection to WorkflowManagementServer fine, but same line of code in a .NET6 console app throws exception Method not found: System.AppDomainManager.

Why? 

 

Where running K2 Five 5.3.

 

Code in 4.8 console app:

 

internal class Program { static void Main(stringr] args) { var k2ConnectionString = "Host=localhost;Port=5555;Integrated=True;IsPrimaryLogin=True;Authenticate=True;EncryptedPassword=False;CachePassword=True"; SourceCode.Workflow.Management.WorkflowManagementServer wfmServer = new SourceCode.Workflow.Management.WorkflowManagementServer(); wfmServer.CreateConnection(); wfmServer.Connection.Open(k2ConnectionString); // works just fine.. //Search error profile and we’ll get the list of errors int errorProfileID = wfmServer.GetErrorProfile("All").ID; SourceCode.Workflow.Management.ErrorLogs errorLogs = wfmServer.GetErrorLogs(errorProfileID);

 

 

Code in .NET6 console app:

 

 

var k2ConnectionString = "Host=localhost;Port=5555;Integrated=True;IsPrimaryLogin=True;Authenticate=True;EncryptedPassword=False;CachePassword=True"; SourceCode.Workflow.Management.WorkflowManagementServer wfmServer = new SourceCode.Workflow.Management.WorkflowManagementServer(); wfmServer.CreateConnection(); wfmServer.Connection.Open(k2ConnectionString); // Throws the error //Search error profile and we’ll get the list of errors int errorProfileID = wfmServer.GetErrorProfile("All").ID; SourceCode.Workflow.Management.ErrorLogs errorLogs = wfmServer.GetErrorLogs(errorProfileID); Console.WriteLine(k2ConnectionString); wfmServer.Connection.Close();

 

 

 

Hi,



 



Versions greater than .net core 2 is not supported when working with the K2 dlls as they user the .net framework. This is down to .net core 3 and up not supporting some legacy code in the .net framework.



 



e.g. using .net core 3.1 you will get an error trying to open a connection such as
roleManager.Connection.Open(ConnectionString);”
It throws an exception with message “Method not found: 'System.AppDomainManager System.AppDomain.get_DomainManager()'”



There is more information in the stack overflow article No AppDomains in .NET Core! Why?  on the subject.




You can however have any version of the .net core framework installed on the K2 Server for other purposes.


Thank you for your answer and knowledge about the frameworks.



Since K2/Nintex does not expose a Web Service or REST API for working with process errors, we need to use the WorkflowManagementServer API (dll).



 



Could we maybe expose the WorkflowManagementServer API through a .NET6 REST API, or is there another workaround?


I'm not in front of K2 Management at the moment, but I believe there are some SmartObjects out there you can invoke to get process errors which might be something you can take advantage of easier than using the assembly API.

You could still use .net framework 4.7 or 4.8.

If that is not an option then you can use the Start a workflow with the Start when any workflow errors event



This would allow you to log the error out either to SmartBox or a custom data store e.g. SQL Server db via a SmartObject. You could then use that data instead.

Another alternative is to use the System SmartObject SystemManagementWorkflowsSmartObjectscom_K2_System_Workflow_SmartObject_ErrorLog that K2 itself uses to show processes that are in error. This SmO also exposes the RetryError method.



I just stumbled upon Ruben's Blog and old posts about exposing the Smart Objects as endpoints and then be able to call them as WCF and maybe as a REST endpoint:



K2 SmartObject Services – Configuration update, static endpoint - Ruben's blog (nettrends.nl)



 



Or do you know a better way to call SmO's from code which would with any .NET version?



Would I be able to call SmO from .NET6 code directly perhaps?



 


Hi,



 



Yes the SmartObject WCF Services are an option  but it is a legacy feature. As of K2 5.6 or K2 Cloud you can use OData v4 which allows you to execute any SmartObject.




For list only SmartObject calls you can use the OData V3 API.



The OData and REST endpoints can be called from code.


Thank you 👍👍

Hi NicS,
I see in the release notes that you can't yet add parameters to an OData v4 call. What's the best workaround? My end goal is to a) Get a certain user's worklist, and b) Redirect a task.


Hi,





I think that the best approach here would be to create a new SmartObject on top of the service object that exposes properties and not parameters.

Here is a link to the documentation on how to make use of the OData V4 API: SmartObject OData API v4 endpoints


Thanks NicS,
We have implemented your advice and are using the OData $filter parameter to narrow down the tasks to a specific user.
However, does this have a negative performance impact compared to using the RegularFilter parameter? I.e. does it enumerate *every* worklist item for the whole business on the server? (We have thousands...)


Reply