when I'm trying to import some service that gets some data from db the dataprovider import is always null ( Object reference not set to an instance of an object). I had a look into the aggregatecatalog and the Assembly which contains Service seems to be loaded correctly. A reference to dataprovider is used in Loaded event of userControl.
interface
public interface IGetSampleData
{
IEnumerable<SampleDataValueObject> GetAllSampleData();
}
service
[Export(typeof(IGetSampleData))]
public class SampleDataService : IGetSampleData
{
private ISampleData dax = new SampleDataRepository();
public IEnumerable<SampleDataItem> GetAllSampleData()
{
throw new NotImplementedException();
}
}
ViewModel
[Export]
public class SampleDataViewModel : BaseViewModel
{
[Import(typeof(IGetSampleData))]
public IGetSampleData DataProvider { get; set; }
//in Loaded event dataprovider is null
var src = this.DataProvider.GetAllSampleData();
}
Thanks for help. Regards