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 Client
was referencing an old DLL of Data
, not the Data
project, 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 all using
statements for Data
, rebuild and get errors, and then replace all the using
s. Now all is working fine.