question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Struggling with strange recursive dependency

See original GitHub issue

Hi, 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:closed
  • Created 5 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
seesharpercommented, Jul 24, 2018

Could you come up with a complete set of steps to reproduce this error?

This is what I’ve got

var container = new ServiceContainer();
container.Register<ObservableCollection<string>>();
container.Compile<ObservableCollection<string>>();

Works fine on my machine 😄

0reactions
adyshimonycommented, Jul 25, 2018

Yep, I didn’t register it 😃 I thought assembly scan enough?

Closing. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Bug]: Stack Overflow on Recursive Dependencies #3434
This appears to be caused by cyclic dependencies where blindly following dependency/devDependency gets you into an infinite loop. For example: A ...
Read more >
npm is installing dependencies in a weird recursive way
I am struggling to find a valid argument for this approach when searching around the web. What is wrong with installing them globally...
Read more >
How to deal with recursive dependencies in OO languages?
Whenever a piece of code needs something, it should take a parameter. Don't do anything more complicated than that.
Read more >
How to conceptually understand recursion and think ...
I'm trying to learn some DSA and get proficient in it but I'm struggling big time with recursion. I've always been good at...
Read more >
Do experienced programmers still get confused while ...
Recursion is different from loops: the best way to think about a loop is to simulate what the computer is doing, running through...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found