I am trying to structure my new application with the help of Dependency Injection.
Created a Autofac module that i want to register with the IServiceCollection interface.
public class PlanrModule : Module
{
protected override void Load(ContainerBuilder builder)
{
//builder.Register(c => new Logger())
// .As<ILogger>()
// .InstancePerLifetimeScope();
}
}
The problem is that i can't reference the Successful.Core.Ioc project, don't ask me why, everything seems correct.
using Successful.Core.Ioc.Modules;
namespace Successful.Planr.Web
{
public class Startup
{
public IServiceProvider ConfigureServices(IServiceCollection services)
{
// Create the Autofac container builder.
var builder = new ContainerBuilder();
// Add any Autofac modules or registrations.
builder.RegisterModule(new PlanrModule());
// Populate the services.
builder.Populate(services);
// Build the container.
var container = builder.Build();
// Resolve and return the service provider.
return container.Resolve<IServiceProvider>();
}
Is there something wrong with the code? Or is the problem relative to my vs setup/installation?
Ok, so i found the answer my self. The project that i referenced was a dnx451 project and my web project was a aspnet project.
Changed so both projects use the dnx runtime.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.