How to Finish the Activity?
===

I am trying to finish the activity after publishing the component from workflow.

Publishing is done, and am getting error ("Object instance not set to an instance object") after setting the finish activity message.

                    ActivityFinishData activityfinish = new ActivityFinishData();
                activityfinish.Message = "Published to WIP Publication Target";
                logdetails("Finish Message able to Set using Code,the below is the finish message");
                logdetails(activityfinish.Message);
                ProcessInstanceData processInstance = new ProcessInstanceData();
                ActivityInstanceData activityInstance = (ActivityInstanceData)processInstance.Activities[0];
                logdetails(activityInstance.Title.ToString());
                logdetails(activityInstance.Id.ToString());
                csClient.FinishActivity(activityInstance.Id, activityfinish, readoption);
                logdetails("Workflow Finished");