0

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?

ProfK
  • 49,207
  • 121
  • 399
  • 775
  • Weird! What else have you tried? Did you clear the bin of possible old assemblies? Is this the only solution hosted on the server/service? – Daniel Hoffmann-Mitscherling Sep 04 '15 at 18:33
  • I'm not familiar with ViewSwitcher so this may be a silly question. When you added it to your solution, did you add it to both projects? And if so, is that necessary? – JDupont Sep 04 '15 at 19:03
  • Yes. The data project was oiginsally the whole project, and when I ended up with only one view, and tons of data modelling, I moved the client stuff into its own project. Yet I've cleared the data project's bin folders and even manually searched the data project's `.csproj` file for the duplicate View Switcher and I can't find it anywhere. I didn't add it myself, it was part of some NuGet package. – ProfK Sep 05 '15 at 04:20

1 Answers1

0

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 usings. Now all is working fine.

ProfK
  • 49,207
  • 121
  • 399
  • 775