Share via


WorkerProcessContainsAppDomain Class [IIS 7 and higher]

Provides a relationship between a worker process and its application domains.

Syntax

class WorkerProcessContainsAppDomain : ObjectContainerAssociation

Methods

This class contains no methods.

Properties

The following table lists the properties exposed by the WorkerProcessContainsAppDomain class.

Name

Description

Container

(Inherited from ObjectContainerAssociation.) A read-only WorkerProcess object that represents an IIS worker process. A key property.

Element

(Inherited from ObjectContainerAssociation.) A read-only AppDomain object that represents an IIS application domain. A key property.

Subclasses

This class contains no subclasses.

Remarks

This association class is useful for retrieving all the loaded application domains for each worker process on a Web server.

Example

The following example displays the loaded application domains on a Web server. The first part uses a WMI query. The second part uses the WorkerProcessContainsAppDomain association class.

' Connect to the WMI WebAdministration namespace.
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")

' Get application domains on the server by using a WMI query.
Set AppDomains = oWebAdmin.ExecQuery ("Select * from AppDomain")

WScript.Echo "AppDomain Count: " & AppDomains.Count
WScript.Echo
For Each AppDomain In AppDomains
    WScript.Echo "AppDomain site name: " + AppDomain.SiteName
    WScript.Echo "AppDomain process ID: " & AppDomain.ProcessID
    WScript.Echo "AppDomain ID: " + AppDomain.Id
    WScript.Echo "AppDomain application path: " & _
        AppDomain.ApplicationPath
    WScript.Echo     
Next

WScript.Echo

' Get the application domains for each worker process by using
' the WorkerProcessContainsAppDomain association.
Set oWorkerProcesses = oWebAdmin.InstancesOf("WorkerProcess")

For Each oWorkerProcess In oWorkerProcesses
    WScript.Echo "Worker Process Process ID: " & oWorkerProcess.ProcessID
    Set oAppDomains = _
    oWorkerProcess.Associators_("WorkerProcessContainsAppDomain")
    
    WScript.Echo "AppDomainCount: " & oAppDomains.Count
    WScript.Echo
    WScript.Echo "List of AppDomains"
    WScript.Echo "------------------"
    For Each oAppDomain In oAppDomains
        WScript.Echo "Application domain process ID: " & _
            oAppDomain.ProcessId
        WScript.Echo "Application domain application path:" & _
            oAppDomain.ApplicationPath
        WScript.Echo " Application domain physical path: " & _
            oAppDomain.PhysicalPath
        WScript.Echo
    Next 
Next

Note the following syntax from the preceding code example.

Set oAppDomains = _

oWorkerProcess.Associators_("WorkerProcessContainsAppDomain")

To simplify your code, you can instead use the following syntax, which enables you to use the association without having to remember its exact name.

Set oAppDomains = oWorkerProcess.Associators_(, "AppDomain")

Inheritance Hierarchy

ObjectContainerAssociation

   WorkerProcessContainsAppDomain

Requirements

Type

Description

Client

Requires IIS 7 on Windows Vista.

Server

Requires IIS 7 on Windows Server 2008.

Product

IIS 7

MOF file

WebAdministration.mof

See Also

Reference

AppDomain Class [IIS 7 and higher]

ObjectContainerAssociation Class [IIS 7 and higher]

WorkerProcess Class [IIS 7 and higher]