Quantcast
Channel: MSBuild Extension Pack
Viewing all articles
Browse latest Browse all 1211

New Post: Iis7AppPool Start throws COMException

$
0
0
I was getting a COMException: The object identifier does not represent a valid object from the Start action of the Iis7AppPool task. Google suggests this might be to do with the Windows Process Activation Service not being ready. I've forked the source and added the following method to catch the exception, wait 100ms and retry up to 3 times:
private void StartAppPoolWithRetry(int retryCount)
{
    try
    {
        this.pool.Start();
    }
    catch (COMException e)
    {
        if (e.Message.Contains("The object identifier does not represent a valid object")
            && retryCount < 3)
        {
            retryCount++;
            LogTaskMessage(string.Format(CultureInfo.InvariantCulture, "..Sleeping and retrying {0}", retryCount));
            Thread.Sleep(100);
            StartAppPoolWithRetry(retryCount);
        }
        else
            throw;
    }
}
Then I'm calling StartAppPoolWithRetry(0) instead of this.pool.Start().

Viewing all articles
Browse latest Browse all 1211

Trending Articles