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.

Func Factories cause a StackOverflow exception

See original GitHub issue

First of all, awesome project, thumb up, hope you continue this project.

I’m in a unique situation that I need a child view model to create a new parent view model; the parent view model is just a kind of content container, so it can create child view model dynamically according to the input model info. Constructors look like this:

ParentViewModel(Func<ChildViewModel> childViewModelFactory)
ChildViewModel(Func<ParentViewModel> parentViewModelFactory)

When build it’ll cause a StackOverflow. I’ve read “Circular Dependencies” wiki, but i still do not know how to configure a Func Factory.

Then I try to use Abstract Factories, it can avoid the stackoverflow exception, but I still wonder why Func Factory fails in this scenario.

Thank you in advance

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

canton7commented, Apr 5, 2017

I think it probably gets caught in this cycle:

  1. It tries to find out how to construct a ParentViewModel
  2. To do this, it needs to work out how to construct a ChildViewModel
  3. In order to construct a ChildViewModel, it needs to know how to construct a ParentViewModel
  4. etc

I’ll investigate when I get some time (slightly snowed under at the moment, sorry), and see if there’s an easy fix.

RyanYANG52commented, Apr 5, 2017


Read more comments on GitHub >

github_iconTop Results From Across the Web

Why am I getting stackoverflow exception when calling a ...
The problem I'm facing is that when the 'handlemobimodals()' function is called for a second time within the test, I get a Stack...
Read more >
Professional AngularJS - Page 98 - Google Books Result
... will cause an error: m.factory('myService', function($scope) { // Error: $scope ... discussion topic on question and answer forums like Stack Overflow.
Read more >
StackOverflowException Class (System)
The exception that is thrown when the execution stack exceeds the stack size. This class cannot be inherited.
Read more >
InfoWorld - Dec 19, 1994 - Page 55 - Google Books Result
... the latter statement fails, generating a runtime error. ... property, function, method, and statement, is available from Microsoft Press at extra cost ......
Read more >
stack overflow exception, have no idea what and where!!
this condition is likely never met, causing your code to run forever until the stack just cant store what is necesary for another...
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 Post

No results found

github_iconTop Related Hashnode Post

No results found