开发者

Rename ASP.NET MVC project resulting in multiple types for controller error

开发者 https://www.devze.com 2023-03-13 06:29 出处:网络
This has happenned before and I can\'t remember how I solved it. I renamed an MVC project then did a ReSharper refactor to update the namespaces. Now when I run I get the following error when I run th

This has happenned before and I can't remember how I solved it. I renamed an MVC project then did a ReSharper refactor to update the namespaces. Now when I run I get the following error when I run the project:

Multiple types were found that match the controller named 'Dashboard'. This can happen if the route that services this request ('{controller}/{action}/{id}') does not specify namespaces to search for a controller that matches the request. If this is the case, register this route by calling an overload of the 'MapRoute' method that takes a 'namespaces' parameter.

The request for 'Dashboard' has found the following matching controllers:
EkmDomains.FrontEnd.Controllers.DashboardController
EkmDomains.Web.Controllers.DashboardController
开发者_运维问答

I have done a search for everywhere in the solution where the old EkmDomains.FrontEnd namespace ocurrs and replaced it with the new one but to no avail...

Anyone have any ideas?


Haha I just remembered how I did it last time - you have to manually delete the old dll's from the bin folder. Doing a clean doesn't get rid of them because a clean only delete's DLL's that match the project name - hence it leaves the DLL's with the old project name.


Adding a few more for anyone else. These cost me an hour of my life that I'm not getting back.

  1. Delete not only \bin files, but also \obj\debug and \release too.

  2. Delete temporary ASP.NET files.

  3. Check for any references to old DLL name in web.config.

  4. Check all web.config files. Sometimes one is added to the Views folder too.


Alternatively, you can follow these simple steps.

  1. Go to your Project Solution Explorer
  2. Right-click on Global.asax file
  3. Select "Open-with" option
  4. Select "Global.asax File Editor with Encoding"
  5. Click Ok and you can change the code to rectify the error yourself.

Try it! It worked for me.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号