ContentManager Constructor (IServiceProvider, String)

Initializes a new instance of ContentManager.

Syntax

'Declaration
Public Sub New ( _
         serviceProvider As IServiceProvider, _
         rootDirectory As String _
)
public ContentManager (
         IServiceProvider serviceProvider,
         string rootDirectory
)
public:
ContentManager(
         IServiceProvider serviceProvider,
         String rootDirectory
)

Parameters

  • serviceProvider
    Type: IServiceProvider
    The service provider the ContentManager should use to locate services.
  • rootDirectory
    Type: String
    The root directory to search for content.

Exceptions

Exception type Condition
ArgumentNullException The serviceProvider or rootDirectory parameter is null.

Remarks

Warning

When creating a new ContentManager, if no instance of Game is otherwise required by the application, it is often better to create a new class that implements the IServiceProvider interface rather than creating an instance of Game just to create a new instance of GraphicsDeviceManager.

Example

To create a ContentManager that uses Game.Services and searches for resources from the root of the C: drive:

ContentManager contentManager = new ContentManager( Services, "C:\\" );

Requirements

Namespace: Microsoft.Xna.Framework.Content

Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)

See Also

Reference

ContentManager Class
ContentManager Members
Microsoft.Xna.Framework.Content Namespace

Platforms

Windows Phone