Skip to main content
All docs
V24.2
.NET 8.0+

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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"));
    // ...
}