Castle Windsor Captive dependency

48 views Asked by At

Prerequisites:

  • Castle Windsor 4.1.0
  • Net Framework 4.7.2
  • A large sequence of parallel requests

Parties:

  • API controller
  • Service A as a singleton (default lifestyle for Castle Windsor)
  • Service B as a scoped, injected to the Service A

Error:

  1. Time to time the Service B, during method execution throws a System.NullReferenceException: Object reference not set to an instance of an object.

Questions:

  • Is it valid from my side to guess that, the Service B (scoped), at some time can be disposed, thus, it can be reasonable for the issue (null reference exception). Unfortunately, was able to reproduce it locally, thus, need to get some confirmation for my thoughts
  • How the scoped service behave itself when there is an unhandled error occurred, will it be disposed ? Can it be reason of the issue ?
  • I would be very grateful if there is advice on how to reproduce this locally
0

There are 0 answers