One is written successfully and working well.
With the second one is problem. I just can't understand, there is totaly the same code (excluding classname) as in the first one.
here is stack:
No parameterless constructor defined for this object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.MissingMethodException: No parameterless constructor defined for this object.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[MissingMethodException: No parameterless constructor defined for this object.]
System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache) +98
System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) +241
System.Activator.CreateInstance(Type type, Boolean nonPublic) +69
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +67
[InvalidOperationException: An error occurred when trying to create a controller of type 'Nop.Plugin.ProductsImport.VendorCategories.Controllers.ProductsImportVendorCategoriesController'. Make sure that the controller has a parameterless public constructor.]
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +182
System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) +80
System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +74
System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +218
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +49
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +50
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +16
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8970356
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
and here is dependency injection
public class VendorCategoryDependencyRegistrar : IDependencyRegistrar
{
private const string CONTEXT_NAME = "nop_object_context_vendorcategory";
public void Register(ContainerBuilder builder, ITypeFinder typeFinder)
{
var dataSettingsManager = new DataSettingsManager();
DataSettings dataSettings = dataSettingsManager.LoadSettings();
builder.Register<IDbContext>(c => RegisterIDbContext(c, dataSettings)).Named<IDbContext>(CONTEXT_NAME).InstancePerHttpRequest();
builder.Register(c => RegisterIDbContext(c, dataSettings)).InstancePerHttpRequest();
builder.RegisterType<VendorCategoryService>().As<IVendorCategoryService>();
builder.RegisterType<EfRepository<VendorCategory>>().As<IRepository<VendorCategory>>().WithParameter(ResolvedParameter.ForNamed<IDbContext>(CONTEXT_NAME)).InstancePerHttpRequest();
}
public int Order
{
get { return 0; }
}
/// <summary>
/// Registers the I db context.
/// </summary>
/// <param name="componentContext">The component context.</param>
/// <param name="dataSettings">The data settings.</param>
/// <returns></returns>
private VendorCategoryObjectContext RegisterIDbContext(IComponentContext componentContext, DataSettings dataSettings)
{
string dataConnectionStrings;
if (dataSettings != null && dataSettings.IsValid())
{
dataConnectionStrings = dataSettings.DataConnectionString;
}
else
{
dataConnectionStrings = componentContext.Resolve<DataSettings>().DataConnectionString;
}
return new VendorCategoryObjectContext(dataConnectionStrings);
}
}
where it could be wrong?
Thanks a lot!