Blog posts tagged with 'debugging'
Many people have asked me how to build custom dialogs in Workflow Studio. Enough people have asked that I have built custom dialogs as native tasks in Workflow Studio and I have also built them in PowerShell (something you could do right now with the tech preview.) Before I post more information on how to do this though I want to better understand why people want to have custom dialogs.
An example that I often hear is that someone wants to modify one of our samples to prompt the user for their username and password in the same dialog instead of using two dialogs. Another example I hear is that people would like a multi-column display tool (like a grid) to display the contents of objects output from other tasks. When people ask me for this I begin to wonder how they plan to use the workflow once they get beyond testing it. When we created those samples we included the user input to ensure that the user is aware of what the workflow is doing and to provide a way for them to input the settings specific to their environment. We expect that most people will deploy workflows with these settings pre-configured in the tasks directly or by using the "Set Variable Value" task and that any output would be to XML files or other tasks.
I wrote a post on IT Process Automation with Workflow Studio that looks at some of the use cases we expect Workflow Studio to be used for. Read through that earlier post for a little deeper look at how I think workflows will be used. [And if you think I am wrong please leave me a comment or send me an email...]
With that post in mind, I believe that the people requesting richer interaction from a workflow are either looking to do a lot of "On-Demand Automation" or they are looking for Workflow Studio to offer a richer set of debugging tools for desiging and debugging workflows. If you have read this far then take my poll and tell me which you think it is for you?
In my last post I walked you through creating a workflow based on a template (the included "Start Stopped Services" workflow.) In that post I mentioned that you might want to modify the workflow to only show services that are not in the disabled state and suggested you try to figure out how to do that on your own: Previous Post
Let's take a look at the previous workflow we created to see how it is structured: 
This workflow has 5 basic steps:
- Get all the installed services (Get-Service)
- Filter out all the stopped services (Where-Object)
- Sort the list of services in alphabetical order for display to the user (Sort-Object)
- Display the sorted list to the user and allow them to choose a subset of services to start (User Option)
- Start the services that were selected by the user (For Each Object)
It should be obvious that if we modify the "Where-Object" task to also filter out services that are Disabled in addition to the Stopped ones we can achieve the desired result. Unfortunately, the Status property only returns two different values - "Running" and "Stopped". We need to take a look at what other properties there are on the Get-Service task that we could use. The easiest way to do this is to just output the entire object to a file and take a look at what is there. We include two tasks with Workflow Studio that allow you to send objects to a file - "Export To CSV" and Export To XML". Both of these tasks also include a property to auto-generate an HTML wrapper for the data so you can quickly view the data as well.
To use this debugging technique, just add the additional task from the Input/Output folder (either CSV or XML) and connect it to the "Get-Service" task: 
There is no need to delete the other tasks as Workflow Studio will only run the tasks that are connected in the workflow. On the newly added task you will have to set the "Input Variable" property to "$Services" and the "Output XML File" property to a valid local path and pick a filename. I also set the "Save As HTML" and "Show HTML" properties to TRUE so that I get an immediate, readable HTML report of the object like this: 
If you have followed along this far I hope that this helps you understand how you can output objects to a file for debugging purposes (or you may need to do it to provide files to other processes.) When you look at the properties that are available from the Get-Service task you will find that there is not a property available that will allow you to determine if a service is Disabled. The Get-Service task is based directly on the Get-Service PowerShell cmdlet and this is a limitation of that cmdlet. So we went through this whole process and have hit a dead end with our goal of filtering out disabled services. Next time I will provide the solution to this problem, but in the mean time here is a good hint:
http://msdn.microsoft.com/en-us/library/aa394418(VS.85).aspx
Recently I have to debug a .net windows service I wrote in dev studio 2005. I found this nice article on MSDN about .net windows service debugging.
However when I tried to attach to the running service, the process that has my service name is grayed out in the dev studio debugger and I can attach to it. After examining it more carefully, I realized that this is actually the hosting process CpsPowerMgrService.vhost.exe instead of the service executable CpsPowerMgrService.exe. And the hosting process is running under the current user instead of the local service account I specified for the service.
So where is my service process?
It turns out that I need to check the process in all sessions option and then my real service process showed up. And it is running in a different session as you can see from the session ID column. Now the dev studio allows me to attach to the real process.
I am not sure how useful the hosting process is in this scenario. It seems to only cause unnecessary confusion. It may be a good question for Microsoft. idea, anyone?
This link explains the hosting process feature in dev studio
http://msdn2.microsoft.com/en-us/library/ms185331(VS.80).aspx
would have included some screen shots. But I still haven figured out how to add images to this blog site. Yes, I tried and it is frustrating. I will post screen shots when I can.