Error when create a new DependencyRegistrar for a plugin

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 anos atrás
What files are in your plugin directory? I mean already deployed plugin (\Nop.Web\Plugins\YourPluginName)
12 anos atrás
a.m. wrote:
What files are in your plugin directory? I mean already deployed plugin (\Nop.Web\Plugins\YourPluginName)

Thanks for your reply. Here are the files in Koneka.Banners folder

Description.txt
Nop.Plugin.Koneka.Banners.dll
Nop.Plugin.Koneka.Banners.pdb
12 anos atrás
triho wrote:
What files are in your plugin directory? I mean already deployed plugin (\Nop.Web\Plugins\YourPluginName)
Thanks for your reply. Here are the files in Koneka.Banners folder

Description.txt
Nop.Plugin.Koneka.Banners.dll
Nop.Plugin.Koneka.Banners.pdb


I removed the DependencyRegistrar all together and do the linking manually within the Controller. So it works now.

Thanks guys
12 anos atrás
What do you mean by "linking manually within the Controller"?
12 anos atrás
a.m. wrote:
What do you mean by "linking manually within the Controller"?


What I need to link is my BannerRecordContext to the IDBContext. This is usually done in the DependencyRegister because BannerRecordContext needs the connection string to talk to the database and retrieve the records. So instead of doing it in DependencyRegistrar which gives me error, for now I'm connecting it in the Controller

[AdminAuthorize]
    public class BannersController: Controller
    {
        private readonly BannerRecordContext _bannerRepository;
        private readonly IWidgetService _widgetService;

        /// <summary>
        /// Main Constructor
        /// </summary>
        public BannersController(IWidgetService widgetService)
        {
            /// Create the database connections
            /// This code will later be binded in a different file. For now it's here to keep everything together
            var dataSettingsManager = new DataSettingsManager();
            var dataProviderSettings = dataSettingsManager.LoadSettings();

            _bannerRepository = new BannerRecordContext(dataProviderSettings.DataConnectionString);
            /// --------------------------------------------------------------------------------------

            _widgetService = widgetService;
        }

        public ActionResult Index(int widgetId)
        {
            BannerRecord model = new BannerRecord();

            return View("Nop.Plugin.Koneka.Banners.Views.Banners.Index", model);
        }

        public ViewResult Configure()
        {
            return View("Nop.Plugin.Koneka.Banners.Views.Banners.Configure", _bannerRepository.Banners.ToList());
        }
    }


So it works for now, even though it is not as nice as it's supposed to be. I will come back and try to figure why the DependencyRegistrar gives me error later on. Or if you know, please tell me :)

Thanks..NopCommerce 2.1 is awesome
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.