I have an MVC 5 based solution, with a Client and Data project. It includes the partial _ViewSwitcher as I want to serve mobile and desktop browsers. On the home page, when I click the ViewSwitcher's Mobile view link, I get the following exception:
Multiple types were found that match the controller named 'ViewSwitcher'....
The request for 'ViewSwitcher' has found the following matching controllers:
PayCaddy.Data.Controllers.ViewSwitcherController
PayCaddy.Client.Controllers.ViewSwitcherController
I have done a solution wide search on all files for the term (not whole word) 'ViewSwitcher', and found only one .cs result, in the.Clientproject, and three results in_Layout.Mobile.cshtmland_ViewSwitcher.cshtml`. Plus I have manually checked the file system for any duplicate and found none.
What could be causing this?
It turns out that
Clientwas referencing an old DLL ofData, not theDataproject, i.e. it was an 'assembly reference' instead of a 'project reference'. Deleting the old DLL, and switching the reference to a project reference did the trick. But, not before I had to remove allusingstatements forData, rebuild and get errors, and then replace all theusings. Now all is working fine.