title: The configuration is invalid. The type Service is directly or indirectly depending on itself
body: <p><strong>Error:</strong></p>
  
  <blockquote>
    <p>The configuration is invalid. Creating the instance for type IUserService failed. The configuration is invalid. The type PatientService is directly or indirectly depending on itself. The cyclic graph contains the following types: PatientService -> ConfigService -> PatientService.</p>
  </blockquote>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>var container = new Container();
  container.Register&lt;IUserService, UserService&gt;();
  container.Register&lt;IPatientService, PatientService&gt;();
  container.Register&lt;IConfigService, ConfigService&gt;();
  
  container.RegisterMvcControllers(Assembly.GetExecutingAssembly());
  container.Verify();
  </code></pre>
  
  <p><strong>PatientService:</strong></p>
  
  <pre><code>public class PatientService : IPatientService
      {
          private readonly IPatientRepository _patientRepository;
          private readonly ConfigService _configService;
          private readonly UserService _userService;
  
          public PatientService(
              PatientRepository patientRepository, 
              ConfigService configService, 
              UserService userService)
          {
              _patientRepository = patientRepository;
              _configService = configService;
              _userService = userService;
          }
  }
  </code></pre>
  
  <p><strong>ConfigService:</strong></p>
  
  <pre><code>public class ConfigService : IConfigService
      {
          private readonly PatientService _patientService;
          private readonly IPatientRepository _patientRepository;
  
          public ConfigService(
              PatientService patientService, PatientRepository patientRepository)
          {
              _patientService = patientService;
              _patientRepository = patientRepository;
          }
  }
  </code></pre>
  
  <blockquote>
    <p>I have to use PatientService object in ConfigService and ConfigService
    object in PatientService. Is there a way to tackle this issue?</p>
  </blockquote>