Skip to main content
All docs
V24.1
.NET Framework 4.5.2+

XAF0004: Implement XAF controller constructors correctly

  • 2 minutes to read

Severity: Warning

XAF has the following requirements for Controllers:

Limitations

Examples

Invalid Code

using DevExpress.ExpressApp;
using DevExpress.Persistent.BaseImpl;

namespace MySolution.Module.Controllers{
    public class ExampleClass1 : Controller {
        // The constructor must be public
        ExampleClass1 () {} // Warning: XAF0004
    }

    public class ExampleClass2 : Controller {
        public ExampleClass2 (IXafApplicationProvider appProvider){} // Warning: 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() {}
    }
    // Even though the Controller class and its constructor are not public, this implementation meets the requirements
    class ExampleClass2 : Controller {
        internal ExampleClass2(string theParameter) { }
    }
    // ...
    ShowViewParameters showViewParameters = /*...*/;
    showViewParameters.Controllers.Add(new ExampleClass2("MyParameter"));
    // ...
}