Friday, September 30, 2016
How to find and deactivate a problematic Controller "on the fly" via an application UI for troubleshooting purposes
I wanted to repost a troubleshooting tip our old XAFer and MVP Dave Hesketh has kindly provided in the Support Center today. BTW, Dave also provides XAF training and custom development services, based out of Ontario, Canada, so this may be not the last thing you would want to learn from him and his website.
So, let me focus on the problem and solution he described at https://www.devexpress.com/kb=T433881 and also also quickly show it all in action with one of the XAF demos:
"I have come across a few scenarios where something seems to be slowing down an XAF solution and it is tough to determine where the issue exists. This can then lead to hours of tearing out controllers to try and determine if one is problematic.
To make this process easier, I have created a module that you can add to an XAF solution to Enable and Disable controllers on the fly.
Once you add this module to your solution, you will find the "" action in the Tools menu. In the dialog that appears, you can enable or disable any controllers you wish, or click the "" to disable non-DevExpress controllers (A good starting place).
This solution has been tested on existing Win Applications only."
I remember a couple of similar requests from other guys, and indeed, this dynamic exclusion of Controllers without recompiling and restarting the whole app can be helpful when researching certain complex problems like performance or behavioral/visual side effects. For many other cases, the built-in Diagnostic Action, application log files, and performance profilers would suffice pretty well.
Anyway, let's check how to use Dave's module with our MainDemo.Win app. Consider the following steps:
1. Download the module's source from the SC ticket above and include the ControllerManagement.Module project into your solution via the Solution Explorer. Then, make sure the project can be built without errors (it's currently for v16.1.6 and it is OK, but you may later use the Project Converter tool for automatic version conversion).
2. In the YourSolutionName.Module project, invoke the Module Designer and drop Dave's module from the Toolbox. If the component is unavailable in the Toolbox, you may want to adjust the Target Framework to be 4.0 instead of 4.5 on the project properties page and rebuild your solution. This is exactly my case, as I plan to use this feature in a .NET 4.0 project (our MainDemo app).
3. Run the WinForms app and execute the "Show Controller Settings" command under the Tools menu group. In the opened dialog, you can see and search both system and custom Controllers and deactivate them as you want. Note that you will need to reopen the tested Views in the app after performing these manipulations.
That's it. For instance, I ensured that this method really works by disabling the standard Controller responsible for the SaveXXX commands (you can learn more about standard XAF Controllers from the docs).
As always, I am looking forward to hearing your feedback.