Hi, I am using Dependency Injection to Inject interface into my few views. One of the requirement I need to Inject the interface into the custom control. I have tried using ServiceDependency attribute to inject interface , but it doesn't work.
public interface ISearchService
{
void CustomizeLayout(ColumnCollection collection);
}
IService _service;
[ServiceDependency]
public IService Service
{
get
{
return _service;
}
set
{
_service = value;
}
}
then i m calling Service.CustomizeLayout(this.Columns) in my custom control. It throws Object ref not set to instance of an object (Service comes as a null).
Can somebody tell me wat could be the problem or how to inject dependency into a control similar way which we do for the win forms.