Quantcast
Channel: Managed Extensibility Framework
Viewing all articles
Browse latest Browse all 265

New Post: MEF and generic class

$
0
0
Hello. I use Autofac Mef integration framework in my windows service project. I define several modules
and bind them when service start. But don't know how I can move my Repository class in separate module.
In my program i define Repository class as generic.
For example
public class Repository<T>: IRepository<T>, IDisposable where T : class
{
.........
}

[InheritedExport]
public interface IRepository<T>
{
....
}

I define InheritedExportAttribute in my interface for export in MEF modules.
But AutofacMef Integration doesn't find default constructor for any class,
which I define in generic class.
Is it possible to use this way at all? thank for help

My error:
Autofac.Core.DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'SolarRadiationCell.Host.HostService' can be invoked with the available services and parameters:

Cannot resolve parameter 'SolarRadiationCell.Service.Shared.IRepository1[SolarRadiationCell.Data.History.IHistory] _repository' of constructor 'Void .ctor(SolarRadiationCell.Service.Shared.IRepository1[SolarRadiationCell.Data.History.IHistory])'.

at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)

Viewing all articles
Browse latest Browse all 265

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>