gpt4 book ai didi

asp.net-mvc - Nopcommerce 新表服务注册错误

转载 作者:行者123 更新时间:2023-12-01 08:39:34 27 4
gpt4 key购买 nike

请帮帮我。我坚持服务注册。我尝试了谷歌的每一个可能方面,但无法得出结论。我想要做的是创建一个新表 EducationDegree,一个主表。消费者随后将被分配教育学位。
我的问题与 EducationDegreeService 注册有关。请参阅在 Nop.web>Controllers> CustomController.cs 中创建的构造函数和在 Nop.web>Framework> dependencyregister.cs 中完成的注册。附加代码评论为 //由 Shyam 添加已经一个多星期了,我一直没能破解。所以请帮帮我。

下面是错误信息

在“Nop.Web.Controllers.CustomerController”类型上使用“Autofac.Core.Activators.Reflection.DefaultConstructorFinder”找到的构造函数都不能用可用的服务和参数调用:无法解析构造函数'Void .ctor(Nop.Services.Authentication.IAuthenticationService,Nop.Services.Helpers.IDateTimeHelper,Nop.Services.Helpers.DateTimeSettings,Nop.Core.Domain。 Tax.TaxSettings,Nop.Services.Localization.ILocalizationService,Nop.Core.IWorkContext,Nop.Core.IStoreContext,Nop.Services.Stores.IStoreMappingService,Nop.Services.Customers.ICustomerService,Nop.Services.Customers.ICustomerAttributeParser,Nop。服务。客户Nop.Core.Domain.Common.AddressSettings,Nop.Core.Domain.Forums.ForumSettings,Nop.Core.Domain.Orders.OrderSettings,Nop.Services.Common.IAddressService,Nop.Services.Directory.ICountryService,Nop.Services。可怕的ctory.IStateProvinceService,Nop.Services.Orders.IOrderTotalCalculationService,Nop.Services.Orders.IOrderProcessingService,Nop.Services.Orders.IOrderService,Nop.Services.Directory.ICurrencyService,Nop.Services.Catalog.IPriceFormatter,Nop.Services.Media。 IPictureService,Nop.Services.Messages.INewsLetterSubscriptionService,Nop.Services.Forums.IForumService,Nop.Services.Orders.IShoppingCartService,Nop.Services.Authentication.External.IOpenAuthenticationService,Nop.Services.Catalog.IBackInStockSubscriptionService,Nop.Services.Media。 IDownloadService、Nop.Core.IWebHelper、Nop.Services.Logging.ICustomerActivityService、Nop.Core.Domain.Media.MediaSettings、Nop.Services.Messages.IWorkflowMessageService、Nop.Core.Domain.Localization.LocalizationSettings、Nop.Web.Framework。 UI.Captcha.CaptchaSettings, Nop.Core.Domain.Customers.ExternalAuthenticationSettings, Nop.Services.EducationDegrees.EducationDegreeService)'

这是我添加的代码

Nop.Core>领域 >Educationdegrees

using Nop.Core.Domain.Localization;

namespace Nop.Core.Domain.EducationDegrees
{
public partial class EducationDegree: BaseEntity, ILocalizedEntity
{

/// <summary>
/// Gets or sets the name
/// </summary>
public string Name { get; set; }

/// <summary>
/// Gets or sets the page size
/// </summary>
public int PageSize { get; set; }

/// <summary>
/// Gets or sets a value indicating whether customers can select the page size
/// </summary>
public bool AllowCustomersToSelectPageSize { get; set; }

/// <summary>
/// Gets or sets the available customer selectable page size options
/// </summary>
public string PageSizeOptions { get; set; }
}
}

Nop.Data>Mapping>教育程度 – EducationDegreeMap.cs

using System.Data.Entity.ModelConfiguration;
using Nop.Core.Domain.EducationDegrees;

namespace Nop.Data.Mapping.EducationDegrees
{
public partial class EducationDegreeMap : EntityTypeConfiguration<EducationDegree>
{
public EducationDegreeMap()
{
this.ToTable("EducationDegree");
this.HasKey(v => v.Id);
this.Property(v => v.Name).IsRequired().HasMaxLength(1000);
}
}
}

Nop.Services>EducationDegree>EducationDegreeService.cs

using System;
using System.Linq;
using Nop.Core;
using Nop.Core.Data;
using Nop.Core.Domain.EducationDegrees;
using Nop.Services.Events;

namespace Nop.Services.EducationDegrees
{
public partial class EducationDegreeService : IEducationDegreeService
{
#region Fields

private readonly IRepository<EducationDegree> _educationdegreeRepository;
private readonly IEventPublisher _eventPublisher;

#endregion

#region Ctor

/// <summary>
/// Ctor
/// </summary>
/// <param name="educatioRepository">Vendor repository</param>
/// <param name="eventPublisher">Event published</param>
public EducationDegreeService(IRepository<EducationDegree> educationdegreeRepository,
IEventPublisher eventPublisher)
{
this._educationdegreeRepository = educationdegreeRepository;
this._eventPublisher = eventPublisher;
}

#endregion

#region Methods
/// <summary>
/// Gets all vendors
/// </summary>
/// <param name="showHidden">A value indicating whether to show hidden records</param>
/// <param name="pageIndex">Page index</param>
/// <param name="pageSize">Page size</param>
/// <returns>Vendors</returns>
public virtual IPagedList<EducationDegree> GetAllEducationDegrees(int pageIndex = 0, int pageSize = int.MaxValue, bool showHidden = false)
{
var query = _educationdegreeRepository.Table;
query = query.OrderBy(v => v.Name);

var educationdegrees = new PagedList<EducationDegree>(query, pageIndex, pageSize);
return educationdegrees;
}
#endregion
}
}

Nop.Services>EducationDegree>IEducationDegreeService.cs

using Nop.Core;
using Nop.Core.Domain.EducationDegrees;

namespace Nop.Services.EducationDegrees
{
public partial interface IEducationDegreeService
{
/// <summary>
/// Gets all vendors
/// </summary>
/// <param name="showHidden">A value indicating whether to show hidden records</param>
/// <param name="pageIndex">Page index</param>
/// <param name="pageSize">Page size</param>
/// <returns>Vendors</returns>
IPagedList<EducationDegree> GetAllEducationDegrees(int pageIndex = 0, int pageSize = int.MaxValue, bool showHidden = false);

}
}

Nop.Web>基础结构>DependencyRegister.cs

using Autofac;
using Autofac.Core;
using Nop.Core.Caching;
using Nop.Core.Infrastructure;
using Nop.Core.Infrastructure.DependencyManagement;
using Nop.Web.Controllers;
using Nop.Web.Infrastructure.Installation;
using Nop.Services.EducationDegrees;

namespace Nop.Web.Infrastructure
{
public class DependencyRegistrar : IDependencyRegistrar
{
public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder)
{
//we cache presentation models between requests
builder.RegisterType<BlogController>()
.WithParameter(ResolvedParameter.ForNamed<ICacheManager>("nop_cache_static"));
builder.RegisterType<CatalogController>()
.WithParameter(ResolvedParameter.ForNamed<ICacheManager>("nop_cache_static"));
builder.RegisterType<CountryController>()
.WithParameter(ResolvedParameter.ForNamed<ICacheManager>("nop_cache_static"));
builder.RegisterType<CommonController>()
.WithParameter(ResolvedParameter.ForNamed<ICacheManager>("nop_cache_static"));
builder.RegisterType<NewsController>()
.WithParameter(ResolvedParameter.ForNamed<ICacheManager>("nop_cache_static"));
builder.RegisterType<PollController>()
.WithParameter(ResolvedParameter.ForNamed<ICacheManager>("nop_cache_static"));
builder.RegisterType<ProductController>()
.WithParameter(ResolvedParameter.ForNamed<ICacheManager>("nop_cache_static"));
builder.RegisterType<ShoppingCartController>()
.WithParameter(ResolvedParameter.ForNamed<ICacheManager>("nop_cache_static"));
builder.RegisterType<TopicController>()
.WithParameter(ResolvedParameter.ForNamed<ICacheManager>("nop_cache_static"));
builder.RegisterType<WidgetController>()
.WithParameter(ResolvedParameter.ForNamed<ICacheManager>("nop_cache_static"));

//installation localization service
builder.RegisterType<InstallationLocalizationService>().As<IInstallationLocalizationService>().InstancePerLifetimeScope();
//Added by Shyam
builder.RegisterType<EducationDegreeService>().As<IEducationDegreeService>().InstancePerLifetimeScope();
}

public int Order
{
get { return 2; }
}
}
}

Nop.Web>模型>教育程度

using System.Collections.Generic;
using System.Web.Mvc;
using FluentValidation.Attributes;
using Nop.Web.Framework;
using Nop.Web.Framework.Localization;
using Nop.Web.Framework.Mvc;

namespace Nop.Web.Models.EducationDegrees
{

public partial class EducationDegreeModel : BaseNopEntityModel
{
public EducationDegreeModel()
{
}

[NopResourceDisplayName("Education Degree")]
[AllowHtml]
public string Name { get; set; }
}


}

Nop.Web>Models>Customer>registerModel.cs

public RegisterModel()
{
this.AvailableTimeZones = new List<SelectListItem>();
this.AvailableCountries = new List<SelectListItem>();
this.AvailableStates = new List<SelectListItem>();
this.CustomerAttributes = new List<CustomerAttributeModel>();
//Added By Shyam
this.AvailableEducationDegrees = new List<SelectListItem>();
}
//Added By Shyam
public int? EducationDegreeId { get; set; }
public IList<SelectListItem> AvailableEducationDegrees { get; set; }

Nop.Web>Models>Customer>customerinfoModel.cs

//Added by Shyam

[NopResourceDisplayName("What is the highest educational degree that you have obtained (select one)?")]
public int? EducationDegreeId { get; set; }
public IList<SelectListItem> AvailableEducationDegree { get; set; }

Nop.web>Controllers>EducationDegreeController.cs

using System.Linq;
using System.Web.Mvc;
using Nop.Core.Domain.Vendors;
using Nop.Services.EducationDegrees;
using Nop.Web.Framework.Controllers;
using Nop.Web.Framework.Kendoui;

namespace Nop.Web.Controllers
{
public partial class EducationDegreeController : BasePublicController
{
#region Fields
private readonly IEducationDegreeService _educationdegreeService;
#endregion

#region Constructors

public EducationDegreeController(IEducationDegreeService educationdegreeService)
{
this._educationdegreeService = educationdegreeService;
}

#endregion

#region Methods

//list
public ActionResult Index()
{
return RedirectToAction("List");
}

#endregion
}
}

Nop.web>框架>dependencyregister.cs

//Added by Shyam
using Nop.Services.EducationDegrees;
namespace Nop.Web.Framework
{
public class DependencyRegistrar : IDependencyRegistrar
{
public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder)
{
. . . . . . .
. . . . . . . .

//Added by Shyam
builder.RegisterType<EducationDegreeService>().As<IEducationDegreeService>().InstancePerLifetimeScope();
}
}
}

Nop.web> Controller > CustomController.cs

using System;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Nop.Web.Models.Customer;
//Added by shyam
using Nop.Services.EducationDegrees;

namespace Nop.Web.Controllers
{
public partial class CustomerController : BasePublicController
{
#region Fields
private readonly ExternalAuthenticationSettings _externalAuthenticationSettings;

//Added by Shyam
private readonly IEducationDegreeService _educationdegreeService;
#endregion

#region Ctor

public CustomerController(IAuthenticationService authenticationService,
IDateTimeHelper dateTimeHelper,
DateTimeSettings dateTimeSettings,
TaxSettings taxSettings,
ILocalizationService localizationService,
IWorkContext workContext,
IStoreContext storeContext,
IStoreMappingService storeMappingService,
ICustomerService customerService,
ICustomerAttributeParser customerAttributeParser,
ICustomerAttributeService customerAttributeService,
IGenericAttributeService genericAttributeService,
ICustomerRegistrationService customerRegistrationService,
ITaxService taxService, RewardPointsSettings rewardPointsSettings,
CustomerSettings customerSettings,AddressSettings addressSettings, ForumSettings forumSettings,
OrderSettings orderSettings, IAddressService addressService,
ICountryService countryService, IStateProvinceService stateProvinceService,
IOrderTotalCalculationService orderTotalCalculationService,
IOrderProcessingService orderProcessingService, IOrderService orderService,
ICurrencyService currencyService, IPriceFormatter priceFormatter,
IPictureService pictureService, INewsLetterSubscriptionService newsLetterSubscriptionService,
IForumService forumService, IShoppingCartService shoppingCartService,
IOpenAuthenticationService openAuthenticationService,
IBackInStockSubscriptionService backInStockSubscriptionService,
IDownloadService downloadService, IWebHelper webHelper,
ICustomerActivityService customerActivityService, MediaSettings mediaSettings,
IWorkflowMessageService workflowMessageService, LocalizationSettings localizationSettings,
CaptchaSettings captchaSettings, ExternalAuthenticationSettings externalAuthenticationSettings, EducationDegreeService educationDegreeService)
{
//Added by Shyam
this._educationdegreeService = educationDegreeService;

this._authenticationService = authenticationService;
this._dateTimeHelper = dateTimeHelper;
this._dateTimeSettings = dateTimeSettings;
this._taxSettings = taxSettings;
this._localizationService = localizationService;
this._workContext = workContext;
this._storeContext = storeContext;
this._storeMappingService = storeMappingService;
this._customerService = customerService;
this._customerAttributeParser = customerAttributeParser;
this._customerAttributeService = customerAttributeService;
this._genericAttributeService = genericAttributeService;
this._customerRegistrationService = customerRegistrationService;
this._taxService = taxService;
this._rewardPointsSettings = rewardPointsSettings;
this._customerSettings = customerSettings;
this._addressSettings = addressSettings;
this._forumSettings = forumSettings;
this._orderSettings = orderSettings;
this._addressService = addressService;
this._countryService = countryService;
this._stateProvinceService = stateProvinceService;
this._orderProcessingService = orderProcessingService;
this._orderTotalCalculationService = orderTotalCalculationService;
this._orderService = orderService;
this._currencyService = currencyService;
this._priceFormatter = priceFormatter;
this._pictureService = pictureService;
this._newsLetterSubscriptionService = newsLetterSubscriptionService;
this._forumService = forumService;
this._shoppingCartService = shoppingCartService;
this._openAuthenticationService = openAuthenticationService;
this._backInStockSubscriptionService = backInStockSubscriptionService;
this._downloadService = downloadService;
this._webHelper = webHelper;
this._customerActivityService = customerActivityService;


this._mediaSettings = mediaSettings;
this._workflowMessageService = workflowMessageService;
this._localizationSettings = localizationSettings;
this._captchaSettings = captchaSettings;
this._externalAuthenticationSettings = externalAuthenticationSettings;


}
}}

最佳答案

是的,你是对的 user3838557 :

Nop.Web.Controllers 构造函数声明。

而不是声明

"EducationDegreeService educationDegreeService"

你应该用过

IEducationDegreeService educationDegreeService"

关于asp.net-mvc - Nopcommerce 新表服务注册错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34305012/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com