XAF0004: Implement XAF controller constructors correctly
Severity: Error
XAF requires that the controller’s constructor should be public and have no parameters.
If the controller’s class constructor does not meet these requirements, the class is not recognized as a controller.
This diagnostic works only for classes derived from the DevExpress.ExpressApp.Controller class. This diagnostics does not work for abstract classes.
Examples
Invalid Code
using DevExpress.ExpressApp;
using DevExpress.Persistent.BaseImpl;
namespace MySolution.Module.Controllers{
public class ExampleClass1 : Controller {
// The constructor must be public
// ExampleClass1 () {} // Error: XAF0004
}
public class ExampleClass2 : Controller {
// The constructor must be without parameters, Dependency Injection is not supported.
// public ExampleClass2 (IXafApplicationProvider appProvider){} // Error: XAF0004
}
// ...
}
Valid Code
using DevExpress.ExpressApp;
using DevExpress.Persistent.BaseImpl;
namespace MySolution.Module.Controllers {
public class ExampleClass1 : Controller {
// This constructor meets the requirements
public ExampleClass1() {}
}
// ...
}
How to Fix
Declare the controller’s constructor with the public
keyword and without parameters.