Multiple Controllers Found with the Name 'HomeController'

by Mark Berry 7/3/2008 9:25:00 AM

I've been playing with Billy McCafferty's S#arpArchitecture. I decided to strip the Northwind references out of the sample so I could try the framework on my own project. After removing the Northwind-specific files and renaming the remaining files and namespaces to "MyProject," I kept getting this error when I started the application:  "Multiple controllers found with the name 'HomeController'": 



Sometimes I would instead get a message that no HomeController could be found.

The Controllers project contains one (and only one) HomeController class. If I comment out that class, the project starts fine:  the home page appears as expected. There are no other occurrences of "HomeController" anywhere in the solution--so where is the HomeController that is actually running to display the home page?

The Solution 

With the help of Billy McAfferty in the CodePlex forum, I discovered that there were several instances of Northwind-related DLLs and other files hanging about in various bin and Debug folders, especially in the MyProject.Web\bin folder:

MyProject.Controllers\obj\Debug\Northwind.Controllers.csproj.FileListAbsolute.txt
MyProject.Core\obj\Debug\Northwind.Core.csproj.FileListAbsolute.txt
MyProject.Data\obj\Debug\Northwind.Data.csproj.FileListAbsolute.txt
MyProject.Tests\obj\Debug\Northwind.Tests.csproj.FileListAbsolute.txt
MyProject.Web\bin\Northwind.Controllers.dll
MyProject.Web\bin\Northwind.Controllers.pdb
MyProject.Web\bin\Northwind.Core.dll
MyProject.Web\bin\Northwind.Core.pdb
MyProject.Web\bin\Northwind.Data.dll
MyProject.Web\bin\Northwind.Data.pdb
MyProject.Web\bin\Northwind.Web.dll
MyProject.Web\bin\Northwind.Web.pdb
MyProject.Web\obj\Debug\Northwind.Web.csproj.FileListAbsolute.txt
MyProject.Web\obj\Debug\Northwind.Web.dll
MyProject.Web\obj\Debug\Northwind.Web.pdb

I deleted those files, reran the project, and voilà! I'm back to only one HomeController. (I set a breakpoint in my HomeController class just to be sure it is getting there.) Now the default page appears as expected. Just to be safe, I then followed Billy's suggestion to delete all the bin and obj folders and then do a full rebuild:  yep, still works! Thanks Billy.

Related posts

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

9/5/2008 12:26:15 PM

Powered by BlogEngine.NET 1.3.1.0
Theme by Mads Kristensen. Customized by Mark Berry.

About the author

Mark Berry Mark Berry owns MCB Systems, a firm active in both IT administration and .NET software development.

E-mail me Send mail
`

Disclaimer

The opinions expressed herein are my own personal opinions and absolutely represent my employer's views. I'm self-employed! Please keep in mind that what worked for me or someone else may not apply to your situation. Always have a good backup, and use any information here at your own risk!

Entire contents copyright © 2008 by MCB Systems. Sign in