0

I am working on a service fabric application. Specifically, I am adding a CommandInstanceHandler which listens to messages from the service bus..

From the CommandInstanceHandler, I want to call a method in the Controller. However, it's not as simple as instantiating a new instance of the controller and calling the method. The controller is instantiated at startup with several dependency injection.

Is there a way to access the instance of the controller which was instantiated at startup (with all the dependency injections) from a class in the same service fabric application?

Todd Fishburg
  • 215
  • 1
  • 2
  • 9
  • 1
    usually, the solution for such things is not to create an instance of the controller. you can have another service that you can use with DI. this service can be used by both your constructor and else where. – Neville Nazerane Apr 27 '18 at 02:35
  • by the way, if i am not mistaken, controllers set up as services too. have you tried accessing an instance using DI? – Neville Nazerane Apr 27 '18 at 02:36
  • Sounds like you need to refactor you controller, encapsulate the logic into something that can be constructed using the container (without rest of the infrastructure baggage) and then invoke/call that. – Hadi Eskandari Apr 27 '18 at 12:10

0 Answers0