Debugging Your Custom IIS Transform Manager Task

The during an initialization phase, the ITask interface provides your custom task with injected dependent objects, see here for more details on these objects. One challenge while writing a custom ITask implementation is debugging your task with real-time injected values. One approach is to have your debugger launch a finished or failed job in a similar environment as the IIS Transform Manager would. Here are the high level tasks to achieve this:  
  1. Run and locate a job instance
  2. Identify the program and arguments to execute
  3. Setup the working environment
  4. Run the command under your debugger

Run and Locate a Job Instance

To begin, you’ll need to get either a finished or failed job.  At this point, if you have not registered your task with the IIS Transform Manager Service yet you should. See here for more details on this. You should also have a WatchFolder setup using a job template with the custom task in question. Finally, copy all the files that are needed to start a job in the watch folder. This will create a job instance which will either end up in the finished or failed queue. Here’s an example of a failed job instance directory:

This job instance directory contains all the files and metadata needed to run a job.  

Identify the Program and Arguments to Execute

The Job instance directory contains a job manifest file, *.smil. The name of the file matches the directory name as well as the Job Instance ID. In the failed job example above there should be a file in that directory, called 20111028035216_DC0AA2A0A63146B6B0B41B34200FED69.smil, representing the job manifest. If you edit that file, somewhere in the RDF block of the head element, you’ll see what the task scheduler was configured to execute.

   <iisms:program>C:\Program Files\IIS\Transform Manager\TaskEngine.exe</iisms:program>   <iisms:arguments> /taskIndex 1 /manifest 20111028035216_DC0AA2A0A63146B6B0B41B34200FED69.smil</iisms:arguments>
These iisms:program and iisms:arguments values can be used to re-build the TaskEngine.exe command needed to invoke your task. TaskEngine.exe is the IIS Transform Manager executable that loads your assembly, locates the ITask interface class and calls your implementation of the Initialize, Start and Dispose methods.  The /taskIndex 1 argument tells the TaskEngine.exe to locate the first task listed in the job manifest; it’s a 1 based index. If you have more than one task in your Job Template, you’ll need to find the right task . The /manifest tells the TaskEngine.exe where to locate the Job Manifest file.

Setup the Working Environment

One important detail you need to know is that the TaskEngine.exe is expecting to have its working directory set to the parent folder, not the Job instance folder. In this case the failed directory.  At this point you can run the task from a command line by executing these two commands:

cd /D %SystemDrive%\inetpub\media\Transform Manager\MyWatchFolder\WorkQueue\Failed\  

%SystemDrive%\Program Files\IIS\Transform Manager\TaskEngine.exe” /taskIndex 1 /manifest 20111028035216_DC0AA2A0A63146B6B0B41B34200FED69.smil

One more thing to keep in mind; make sure the credentials you are running under are the same as what the Watch Folder settings are configure to run under. Otherwise, you might miss out on some important access/permission issues.

Run the Command Under Your Debugger

Knowing where to run the program from and the command line to execute, you can now launch a windbg session and start debugging.


C:\inetpub\media\Transform Manager\MyWatchFolder\WorkQueue\Failed>c:\Debuggers\windbg.exe "c:\Program Files\IIS\Transform Manager\TaskEngine.exe" /taskIndex 1 /manifest 20111028035216_DC0AA2A0A63146B6B0B41B34200FED69.smil


An alternate approach is to configure your Visual Studio project to launch TaskEngine.exe, using the project's properties. Here’s how:  


From your project's properties:

  1. Click on the Debug vertical tab
  2. Under Start Action, select Start External Program and browse to the TaskEngine.exe found in the job manifest *.smil file, the iisms:program element value.
  3. Under Start Options Paste the Command line arguments found in the job manifest *.smil file in the textbox, the iisms:arguments element value.
  4. Under Start Options set the Working directory to the %Failed% directory location.
  5. If you make changes to the code and want to run again, you may consider configuring Post-Build deployment commands:
    1. Click on the Build Events vertical tab.     
    2. In the Post-build event command line: text box paste the following line
copy /Y "$(TargetPath)" "%systemdrive%\Program Files\IIS\Transform Manager"

Now you should be able to start debugging, (F5), and step through the code or catch exceptions.

Sample Exception Code

From the code you can see the obvious exception being thrown with the message “BadException”. This matches what was found in the windbg debugger session as well as what was caught in Visual Studio. 

You should now be able to debug your own custom task with real-time injected dependent objects running inside a job instance directory with all the files needed to execute your task.    


Published Sunday, November 13, 2011 11:18 PM by Doiron


# re: Debugging Your Custom IIS Transform Manager Task

Monday, September 10, 2012 7:44 AM by louis vuitton

It's a good post.It's a good post.

# re: Debugging Your Custom IIS Transform Manager Task

Sunday, September 16, 2012 10:59 AM by louis vuitton handbags

Helpful information. Lucky me I found your website accidentally, and I'm stunned why this twist of fate didn't happened in advance! I bookmarked it.

# re: Debugging Your Custom IIS Transform Manager Task

Monday, December 31, 2012 10:20 PM by Jimmy Choo Pumps

I am joyful to find so various constructive information at this point within the post, we need increase new techniques in this regard, thanks for sharing

# re: Debugging Your Custom IIS Transform Manager Task

Tuesday, January 1, 2013 3:29 AM by mitchell ness snapback hats

Enjoyed reading  this, very good stuff,  appreciate it. "Nothing happens to any thing which that thing is not made by nature to bear." by Marcus Aurelius Antoninus.

# re: Debugging Your Custom IIS Transform Manager Task

Thursday, January 10, 2013 10:42 AM by

kinda like the article that you posted actually. it really isn't that simple to find good text toactually read (you know READ and not simply browsing through it like some zombie before going somewhere else), so cheers man for not wasting any of my time!

# re: Debugging Your Custom IIS Transform Manager Task

Thursday, January 24, 2013 1:02 PM by

I truly appreciate this post. I've been looking everywhere for this! Thank goodness I found it on Bing. You have made my day! Thx again

# re: Debugging Your Custom IIS Transform Manager Task

Sunday, March 3, 2013 8:27 AM by

wow! thanks for that amazing write-up. I actually cherished it towards the core. Hope you retain putting up these types of remarkable content

Leave a Comment

Powered by Community Server (Commercial Edition), by Telligent Systems