2

I've written a small tool that installs a web application and all needed software packages on a windows server. The tool creates application pools and the needed applications. On my development machine everything works fine, but on a test server (fresh w2k8r2 install with iis) the tool crashes with the following exception:

System.MissingMethodException: Method not found: 'Void Microsoft.Web.Administration.ApplocationPool.set_Startmode(Microsoft.Web.Administration.Startmode)'

This is the code I use to create the appPool:

using (ServerManager serverManager = new ServerManager())
{
    try
    {
        if (!serverManager.ApplicationPools.Any(x => x.Name == appPoolName))
        {
            ApplicationPool appPool = serverManager.ApplicationPools.Add(appPoolName);
            appPool.ManagedRuntimeVersion = "v4.0";
            appPool.StartMode = StartMode.AlwaysRunning;
            appPool.ProcessModel.IdentityType = ProcessModelIdentityType.LocalSystem;

            serverManager.CommitChanges();
        }

        result = true;
    }
    catch (Exception e)
    {
        Console.WriteLine(e);
    }
}

I have installed the IIS managament tools and scripts with the server manager. Am I missing a package or is my code wrong?

Update:

As PhillipH wrote in his answer the IIS 7.5 does not support the property StartMode.

2 Answers 2

2

I can only suggest your development machine isnt running IIS7.5, since 7.5 is the IIS that installs on Server 2008. ApplicationPool.StartMode is listed as a new feature of IIS8.

"Whats new in IIS8" https://blogs.msdn.microsoft.com/vijaysk/2012/10/09/iis-8-whats-new-application-pool-settings/

Sign up to request clarification or add additional context in comments.

3 Comments

I'll check this when im in the office again tomorrow. My dev machine is running on windows 10 and the newest IIS.
So the Server 2008 will be running IIS7.5 and probably doesn't support the StartMode property.
That was it. I have removed the line appPool.StartMode = StartMode.AlwaysRunning; it works like it should.
1

You can check if the attribute exists:

var attr = appPool.Attributes.FirstOrDefault(a => a.Name == "startMode");
if (attr != null) attr.Value = 1; // OnDemand = 0;   AlwaysRunning = 1

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.