ApplicationManager.CreateObject Method (String, Type, String, String, Boolean, Boolean)
Creates an object for the specified application domain based on type, virtual and physical paths, a Boolean value indicating failure behavior when an object of the specified type already exists, and a Boolean value indicating whether hosting initialization error exceptions are thrown.
Assembly: System.Web (in System.Web.dll)
[SecurityPermissionAttribute(SecurityAction.Demand, Unrestricted = true)] [AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)] public IRegisteredObject CreateObject( string appId, Type type, string virtualPath, string physicalPath, bool failIfExists, bool throwOnError )
Parameters
- appId
- Type: System.String
The unique identifier for the application that owns the object.
- type
- Type: System.Type
The type of the object to create.
- virtualPath
- Type: System.String
The virtual path to the application.
- physicalPath
- Type: System.String
The physical path to the application.
- failIfExists
- Type: System.Boolean
true to throw an exception if an object of the specified type is currently registered; false to return the existing registered object of the specified type.
- throwOnError
- Type: System.Boolean
true to throw exceptions for hosting initialization errors; false to not throw hosting initialization exceptions.
| Exception | Condition |
|---|---|
| ArgumentException | physicalPath is null - or - physicalPath is not a valid application path. - or - type does not implement the IRegisteredObject interface. |
| ArgumentNullException | appID is null. - or - type is null. |
| InvalidOperationException | failIfExists is true and an object of the specified type is already registered. |
This overload of the CreateObject method provides the throwOnError parameter, which allows you to control whether hosting initialization exceptions are thrown. The overload of the CreateObject method that does not provide throwOnError calls this overload with the parameter set to false.
- AspNetHostingPermission
for operating in a hosted environment. Demand value: LinkDemand. Permission value: Minimal.
- SecurityPermission
for creating registered objects. Demand value: LinkDemand. Permission value: Unrestricted.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.