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.

Wrong constructor overload gets called

See original GitHub issue

When Locating a class with a default constructor and a constructor with params object[] args the overload with the args always gets invoked even though no configuration for args was Exported. Also the args contains a single object instance.

Version: 7.0.0

Repo:

    var container = new DependencyInjectionContainer();
    container.Configure(x => x.Export<Test>());
    var test = container.Locate<Test>();
    public class Test
    {
        public Test() {}

        public Test(params object[] args)
        {
            throw new Exception("Wrong constructor called");
        }
    }

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ipjohnsoncommented, Aug 12, 2019

Sounds like the container auto registered the class Object and returned an instance in the array.

While not proper I don’t want to change the behavior of discovering object till 8.0 as it’s a breaking change.

0reactions
ipjohnsoncommented, Sep 12, 2019

I’m going to close this out

Read more comments on GitHub >

github_iconTop Results From Across the Web

Wrong constructor is being called - c++
If you pass a const char* , bool overload is preferred over std::string& : ... means a std::string constructor and taking reference.
Read more >
Call of overloaded constructor is ambigu - C++ Forum
When I try to instantiate objects of class Foo in main() of foo.cpp, I keep getting errors about how the call to the...
Read more >
Removing repetitive code (overloading methods and ...
The technique of having two (or more) constructors in a class is known as constructor overloading. A class can have multiple constructors that...
Read more >
Call to overloaded constructor is ambiguous
I am trying to write a class that has two overloaded constructors: One that takes a std::function and another that takes a…
Read more >
Constructor Overloading in C++
Overloaded constructors essentially have the same name (exact name of the class) and different by number and type of arguments.
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