CommandService not accessible from ModuleInit.Star

Topics: CAB & Smart Client Software Factory
Sep 10, 2005 at 11:43 AM
originally posted by: pfilip

When trying to register a command from within ModuleInit's overriden Start() method, CAB cannot access ICommandService (not initialized yet?):

public override void Start()
{
// ...

// register command
ICommandService cmdService = this.GetService<ICommandService>();
if (cmdService != null)
cmdService.RegisterUIElement("ElementSelected", uri, "ElementSelected");
}


In the code above, 'cmdService' gets set to 'null'. If CommandService is attempted to be accessed from inside WorkItem's Run() method, everything is fine.
(Note: The intention is to register a Command associated with a UIElement, and create and run WorkItem from the command handler instead of the module's Start() method).