Export (0) Print
Expand All

BuildManager.GetObjectFactory Method

Gets an object factory for the specified virtual path.

Namespace:  System.Web.Compilation
Assembly:  System.Web (in System.Web.dll)

public static IWebObjectFactory GetObjectFactory(
	string virtualPath,
	bool throwIfNotFound


Type: System.String

The virtual path.

Type: System.Boolean

true to throw an error if the virtual path does not exist; otherwise, false. If the virtual path does not exist and throwIfNotFound is false, this method returns null.

Return Value

Type: System.Web.Util.IWebObjectFactory
The object factory.


The virtual path does not exist.


A higher-level exception already existed when this method was called.


This method was called while the compilation process was building top-level files.


This is a precompiled application and the virtual path was not found in the cache.


A circular reference was detected.

This method returns an object that enables you to generate a type by compiling the virtual path. It returns an object regardless of whether the Web site is precompiled.

.NET Framework

Supported in: 4.5, 4

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft