When using the K2 client API and getting a process instance by calling Connection.OpenProcessInstance(int id), i am trying to get the viewflow URL and the datafields. Both of those properties are throwing exceptions when tryingto access them. Other properties on the process instance all populate fine (name, folio, startdate, etc.).
When I debug the code, sometimes the values populate, sometimes they do not (for the same process instance).
I cannot figure out why these properties throw exceptions.
Here is the code I am using:
using (var connection = new Connection())
{
var connectionStringBuilder = new SCConnectionStringBuilder
{
Authenticate = true,
Integrated = false,
IsPrimaryLogin = true,
EncryptedPassword = false,
Host = k2ConnectionInformation.ServerHostName,
Port = k2ConnectionInformation.WorkflowServerPort,
UserID = k2ConnectionInformation.LoginUserID,
Password = k2ConnectionInformation.LoginUserPassword,
WindowsDomain = k2ConnectionInformation.LoginUserDomain,
SecurityLabelName = k2ConnectionInformation.LoginUserSecurityLabel
};
connection.Open(k2ConnectionInformation.ServerHostName, connectionStringBuilder.ConnectionString);
if (impersonatedUserFqn.HasValue())
{
connection.ImpersonateUser(impersonatedUserFqn);
}
var processInstance = connection.OpenProcessInstance(model.ProcessInstanceID);
}
{
"ClassName": "ClientException",
"Data": null,
"ExceptionMethod": "8
Send
SourceCode.Workflow.Client, Version=4.0.0.0, Culture=neutral, PublicKeyToken=16a2c5aaaa1b130d
SourceCode.Workflow.Client.SocketClient
Void Send(UInt32, SourceCode.Workflow.Client.MessageType, SByte*, Int32)",
"HResult": -2146233088,
"HelpURL": null,
"InnerException": null,
"Message": "Send failed with error: An operation was attempted on something that is not a socket. ",
"RemoteStackIndex": 0,
"RemoteStackTraceString": null,
"Source": "SourceCode.Workflow.Client",
"StackTraceString": "at SourceCode.Workflow.Client.SocketClient.Send(UInt32 sock, MessageType type, SByte* buf, Int32 len)
at SourceCode.Workflow.Client.SocketClient.Send(ClientMessage Msg, Int32 Start, Int32 Length)
at SourceCode.Workflow.Client.InternalConnection.Call(ArchiveX ar, MessageType msgtype)
at SourceCode.Workflow.Client.InternalConnection.CallFunction(ArchiveX ar)
at SourceCode.Workflow.Client.DataField.LoadValue()
at SourceCode.Workflow.Client.DataField.get_MetaData()
at K2.Services.Factories.WorkflowClient.DataFieldModelFactory.Create(DataField dataField)
at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at K2.Services.Factories.WorkflowClient.DataFieldModelFactory.CreateMany(DataFields dataFields)
at K2.Services.Factories.WorkflowClient.ProcessInstanceModelFactory.Create(ProcessInstance processInstance)
at K2.Services.WorkflowClientService.<>c__DisplayClass10_0.<OpenProcessInstance>b__0()
at K2.Services.WorkflowClientService.RunWithK2ClientExceptionHandling(Func`1 code)",
"WatsonBuckets": null
}