getting service as null in the command

rajesh's Avatar


13 Apr, 2011 02:33 PM

Hi, I was trying to access the service in my command. I have mapped service to my interface in the context file as follows.

injector.mapSingletonOf(IServiceName, ServiceName);

and i have below statement in my command.

[Inject] public var service1:IServiceName;

and when i am trying to invoke method on my service1 object, i am getting error of null object reference.

could anybody suggest, what i am doing Wrong here?


  1. 1 Posted by Amy Blankenship on 21 Apr, 2011 12:19 AM

    Amy Blankenship's Avatar

    Can you give more information about what is going on? If you are using SwiftSuspenders (i.e., you didn't change what you were using for the actual dependency injection component, or IInjector), then if your Command is invoked an you've formatted your [Inject] metadata properly and it has compiled properly, it should be injecting or you'd be seeing a different error.

    If you are using RL from Flash and/or you are not using the swc, it is possible your Inject metadata is being lost at compile time.

  2. Support Staff 2 Posted by Stray on 02 May, 2011 12:59 PM

    Stray's Avatar

    If your [Inject] metadata is being kept, could it be that you're trying to run the code in the constructor of the command instead of in execute()?

    The best tool for diagnosing this is the common problems wiki:

    Let us know if this doesn't fix it for you,


  3. Stray closed this discussion on 11 May, 2011 08:42 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac