Beastwood Beastwood - 1 month ago 28
ASP.NET (C#) Question

Simple Injector Web Forms

Okay so I have a UI layer and a BLL layer.

namespace BLL
{
public class User : IUser
{
public void DoSomething(){}
}
public interface IUser
{
void DoSomething();
}
public static class TypeRegistry
{
public static void RegisterTypes(Container container)
{
container.Register<IUser, User>(Lifestyle.Singleton);
}
}
}

namespace UI
{
public partial class Login : System.Web.UI.Page
{
private IUser user;
}
}


I can't figure how to get user to not be null. I have tried making a constructor but that caused an error

public Login(IUser user){ this.user = user;}


Compilation Error : Login does not contain a constructor that takes 0 arguments

Answer