Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing to inject property into ASPNET MVC controller #97

Open
thiagomajesk opened this issue Jun 3, 2016 · 0 comments
Open

Failing to inject property into ASPNET MVC controller #97

thiagomajesk opened this issue Jun 3, 2016 · 0 comments

Comments

@thiagomajesk
Copy link

Hello everyone, I'm trying to simplify the injection code of my application using TinyIoC.
The application fails with the message: no parameterless constructor defined for this object. So it seems that TinyIoC is not injecting the constructor. I don't know if I'm missing something, but my code looks like the one in the docs.

The registrator

 public static class IocConfig
    {
        public static void Register()
        {
            var container = TinyIoCContainer.Current;

            container.Register<IPrincipal>(HttpContext.Current.User);

            container.Register<DatabaseContext>().AsPerRequestSingleton();
        }
    }

And a simple controller

public class HomeController : Controller
    {
        private DatabaseContext context;

        public HomeController(DatabaseContext context)
        {
            this.context = context;
        }

        public ActionResult Index()
        {
            return View();
        }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant