I get the following when using my controller through a front end route.
Fatal error: Uncaught TypeError: Argument 1 passed to Namespace\Module\Controller\Index\Index::__construct() must be an instance of Magento\Framework\App\Action\Context, instance of Magento\Framework\ObjectManager\ObjectManager given, called in /website-magento-2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 93 and defined in /Projects/Work/website-magento-2/app/code/Namespace/Module/Controller/Index/index.php:45 Stack trace: #0 //Projects/Work/website-magento-2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(93): Namespace\Module\Controller\Index\Index->__construct(Object(Magento\Framework\ObjectManager\ObjectManager))
#1 /Projects/Work/website-magento-2/vendor/magento/framework/ObjectManager/Factory/Compiled.php(88): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Namespace\Module...', Array) #2 /Projects/Work/website-magento-2/vendor/magento/framework/ObjectManager/ObjectManager. in /Projects/Work/website-magento-2/app/code/Namespace/Module/Controller/Index/index.php on line 45
Controller construct
public function __construct( Context $context, PageFactory $resultPageFactory, Customer $customer, CustomerSession $customerSession, Session $catalogSession ){ $this->resultPageFactory = $resultPageFactory; $this->context = $context; $this->customer = $customer; $this->customerSession = $customerSession; $this->catalogSession = $catalogSession; parent::__construct($context); } I have seen posts about this issue and the resolution is that I delete and regenerate var/di, createCharge, var/cache. However this isn't working.
bin/magento setup:upgradefollowed bybin/magento cache:flush.