Hi everyone,
Sorry for this question, but neither msdn nor technet are working these days, so I need to call a static method from a menu item, the thing is it calls automatically the main method. I’ve put it this way :

Where InitAllItems() is the static method I want to call. My dev is organized as each static method of this single class will have a menu item button. I know I can seperate each method in a single class, with it’s main method but I find more organized this way, and I want to know if my goal is achievable and how?
Thank you !!
Both MSDN and TechNet works for me without problem.
You can’t do that, at least not directly. Menu item always calls main(), regardless of with which parameters you call it. What you would have to do is adding logic to main() to extract the method name from parameters and call it.
But it’s a suspicious design - for instance, it wouldn’t be checked by compiler, therefore if you a menu item pointed to a non-existing method (e.g. because it’s been renamed), you would find it only at runtime. Or if somebody used parameters, you wouldn’t find it either. You can do it better.
What about using separate classes or an enum parameter instead?
Also note that if you insisted on using method names, you could utilize SysOperation framework. SysOperationServiceController is already capable of parsing Parameters and calling such methods (it works with instance methods and the syntax for Parameters is ClassName.MethodName, such as InitMasterData.InitAllItems). Nevertheless I really believe that it wouldn’t be an optimal design in your case.