I'm trying to use the "Process Data Audit" SmartObject to show the history of a particular data field in an ASP.NET application:
SmartObjectClientServer smartObjectServer = new SmartObjectClientServer();
smartObjectServer.CreateConnection();
smartObjectServer.Connection.Open(Settings.SmartObjectServerConnectionString);
SmartObject smartObject = smartObjectServer.GetSmartObject("Process_Data_Audit");
smartObject.MethodToExecute = "List";
smartObject.Properties["ProcInstID"].Value = processInstanceId.ToString();
smartObject.Properties["Data_Name"].Value = k2FieldName;
SmartObjectList results = smartObjectServer.ExecuteList(smartObject);
This works fine when I run it from a console app or the .NET application.
Now I want to move this code to a WCF service (hosted as a Managed Windows Service) for use with AJAX-style operations. The same code throws SmartObjectException exceptions in this scenario with the following details:
Service: WorkflowReportingService
Service Guid: ef7310e5-b14f-464d-b0f3-a37d6c367620
Severity: Error
Error Message: Object reference not set to an instance of an object.
InnerException Message:
I'm guessing this has something to do with impersonation and the service account the WCF service runs as since the same code works find in other scenarios. My problem is that I can't seem to find an ImpersonateUser() method in the SourceCode.SmartObjects namespace.
Advice on impersonation (or other workarounds) is appreciated.