Struggling with strange recursive dependency
See original GitHub issueHi, I am changing our app to use lighInject indstead of autofac. I an struggling for 2 days with this error. Its happening so far only for a specific view model.
From some reason, it trows an error for BleDevice model.
Recursive dependency detected: ServiceType:System.Collections.Generic.IEnumerable`1[PetActivityMobile.Core.Models.Device.BleDevice], ServiceName:]
When calling :
var viewModel = _container.GetInstance(viewModelType);
I am getting the error. Can’t figure out why, its a very simple model.
namespace PetActivityMobile.Core.Models.Device
{
public class BleDevice
{
public string MacAddress { get; set; }
public string Name { get; set; }
public bool IsConnected { get; set; }
public bool IsAssigned { get; set; }
public string DisplayTitle { get; set; }
public int Index { get; set; }
public string IndexTitle { get; set; }
}
}
The view model is holding a list of this model. Nothing is injected in the constructor. Remove this list from the viewmodel, and the error is gone.
I am registering viewmodels this way:
_container.RegisterAssembly(assembly, (serviceType, implementingType) => serviceType.Namespace.Contains("ViewModel"));
If I can’t solve it, I will have to find another IOC… Any idea?
Thanks,
Ady.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (2 by maintainers)
Top GitHub Comments
Could you come up with a complete set of steps to reproduce this error?
This is what I’ve got
Works fine on my machine 😄
Yep, I didn’t register it 😃 I thought assembly scan enough?
Closing. Thanks!