I'm using telerik
in windows form, so i want to register windows forms in castle.windsor
, but windows form inherited from Telerik.WinControls.UI.RadForm
i cant register this forms.
when my form inherited from "Form" then i don't use from telerik, this form is being registered successfully.
this code register successfully
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
var container = Bootstrapper.WireUp();//return windsoerContainer
container.Register(Classes.FromAssemblyContaining<Form1>()
.BasedOn<Form>().LifestyleTransient());
System.Windows.Forms.Application.EnableVisualStyles();
System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);
System.Windows.Forms.Application.Run(container.Resolve<Form1>());
}
}
this code Does not work
enter code here
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
var container = Bootstrapper.WireUp();//return windsoerContainer
container.Register(Classes.FromAssemblyContaining<FrmLogin>()
.BasedOn<RadForm>().LifestyleTransient());
System.Windows.Forms.Application.EnableVisualStyles();
System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);
System.Windows.Forms.Application.Run(container.Resolve<FrmLogin>());
}
}
public partial class FrmLogin : Telerik.WinControls.UI.RadForm//frm login
{
private readonly ICategoryService _categoryService;
public FrmLogin(ICategoryService categoryService)
{
_categoryService = categoryService;
InitializeComponent();
}
public static class Bootstrapper
{
public static IWindsorContainer WireUp()
{
var container = new WindsorContainer();
container.Register(Component.For<TransactionInterceptor>().LifestylePerWebRequest());
container.Register(Classes.FromAssemblyContaining<CategoryService>()
.BasedOn<IService>()
.WithServiceFromInterface()
.LifestylePerWebRequest().Configure(a=>a.Interceptors<TransactionInterceptor>()));
container.Register(Classes.FromAssemblyContaining<CategoryRepository>()
.BasedOn<IRepository>()
.WithServiceFromInterface()
.LifestylePerWebRequest());
container.Register(Component.For<IUnitOfWork>().ImplementedBy<EfUnitOfWork>().LifestylePerWebRequest());
container.Register(Component.For<CrmDbContext>().LifestylePerWebRequest());
ServiceLocator.SetCurrent(new WindsorServiceLocator(container));
return container;
}
}
Thank you for helping me...
To solve this problem is enough **
.LifestyleSingleton()
**
var container = Bootstrapper.WireUp();//return windsoerContainer
container.Register(Classes.FromAssemblyContaining<FrmLogin>()
.BasedOn<RadForm>().LifestyleSingleton());
System.Windows.Forms.Application.EnableVisualStyles();
System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);
System.Windows.Forms.Application.Run(container.Resolve<FrmLogin>());