Skip to content
This repository was archived by the owner on Nov 2, 2018. It is now read-only.
This repository was archived by the owner on Nov 2, 2018. It is now read-only.

ActivatorUtilities exceptions lack context #386

@wesleyolis

Description

@wesleyolis

Background

Spent about a day of work attempting to resolve exception thrown from the activator.
We have many services from different projects that have been registered and upon integration of all of them, attempting to resolve one the services, the activator failed and threw an error.
This error, of the form "No parameter-less constructor defined", provided absolute no context
of which service failed to resolve. We had to eventually do a process of elimination and manually go register each of the services and binary search to find out which service type that was registered was failing to resolve.

issue

The problem is caused by a private constructor and results in and exception
that may not lead you directly to the source.

Reproduce

Define a class with no public constructors, that inherits from an interface,
then register the service and try resolved the interface.

interface ITestService
{
}
// There are many of these classes.
class TestService :ITestService
{
   TestService()
   {
   }
}

...
var testServices = Container.GetServices<ITestService>();
// Throws exception 'No parameter-less constructor defined'

Suggestions

Provide context to any exceptions throw in the activator,
ideally one would include information about the type being activated
to help track down the culprit(s).

Please let know if you have any future questions or if I can help out in anyway.

/cc @spartan563

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions