@Antoine553 remove generation and di folder from var folder, then check it.
i found the solution
<?php namespace Mymodule\AdminPage\Block\Adminhtml; use Magento\Backend\Block\Template; class Contactslist extends \Magento\Backend\Block\Template { public function __construct( \Magento\Backend\Block\Template\Context $context, \Mymodule\AdminPage\Model\ContactFactory $contactFactory, \Magento\Framework\View\Result\PageFactory $resultPageFactory ) { parent::__construct($context); $this->contactFactory = $contactFactory; $this->resultPageFactory = $resultPageFactory; } public function mycustom(){ echo "test"; } /*public function getAll(){ $data = $this->_objectManager->create('Mymodule\AdminPage\Model\Contact')->getCollection(); foreach ($data as $d ) { echo $d->getToreplace(); echo $d->getReplaceby(); } }*/ }
Issue was in your block file,
Original Class is
\Mymodule\AdminPage\Model\ContactFactory $contactFactory,
You have kept
\Mymodule\AdminPage\Model\Contact $contact,
So you have to keep Factory Object of your Model Class.
After Apply ModelFactory You must delete var/generation folder.