Skip to main content
.NET Framework 4.6.2+

XafApplication.ObjectSpaceProvider Property

Provides access to the application’s Object Space Provider.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v24.2.dll

NuGet Package: DevExpress.ExpressApp

Declaration

[Browsable(false)]
public IObjectSpaceProvider ObjectSpaceProvider { get; }

Property Value

Type Description
IObjectSpaceProvider

An instance of the class that implements the IObjectSpaceProvider interface.

Remarks

XAF uses an Object Space Provider to create Object Spaces. It is a class that implements members of the IObjectSpaceProvider interface. The following Object Space Provider types are supplied with XAF:

By default, XPObjectSpaceProvider is created because the WinForms and ASP.NET Web Forms application project templates override the CreateDefaultObjectSpaceProvider method of the corresponding XafApplication descendant in the following manner:

public partial class MainDemoWinApplication : WinApplication {
//...
    protected override void CreateDefaultObjectSpaceProvider(
        CreateCustomObjectSpaceProviderEventArgs args) {
        args.ObjectSpaceProvider = new XPObjectSpaceProvider(args.ConnectionString, args.Connection);
    }
}

The CreateDefaultObjectSpaceProvider method is called when creating an Object Space Provider during the application’s setup if a particular Object Space Provider is not passed as a parameter in the Setup method call. So, check that an Object Space Provider is not passed in your Setup method call, as in the following code:

static class Program {
    // ...
    public static void Main() {
        // ...
        MainDemoWinApplication application = new MainDemoWinApplication();
        // ...
        application.Setup();
        application.Start();
        // ...
    }
}

To create an Object Space Provider, the application uses the connection string specified using the XafApplication.ConnectionString property. If you need to specify a custom connection string or create an Object Space Provider of another type, implement a custom override of the CreateDefaultObjectSpaceProvider method. Alternatively, you can handle the XafApplication.CreateCustomObjectSpaceProvider event to pass a custom Object Space Provider.

Note

XAF uses the first registered Object Space Provider for the following purposes:

Ensure that NonPersistentObjectSpaceProvider is not the first registered Provider in your application.

Note that in applications with the Application Builder, you need to use the Application Builder’s ObjectSpaceProviders property to register Object Space Providers instead of the XafApplication.CreateDefaultObjectSpaceProvider method or XafApplication.CreateCustomObjectSpaceProvider event to register Object Space Providers. Refer to the following help topic for more information on how to do this: Integrate Application Builders into Existing Applications.

We strongly recommend this because the use of the XafApplication.CreateDefaultObjectSpaceProvider method and XafApplication.CreateCustomObjectSpaceProvider event conflicts with IObjectSpaceFactory and IObjectSpaceProviderFactory service usage.

This technique also improves performance of your application because the application instance is not created in this case.

See Also