16

I renamed my project from MyProjectName to MyNewProjectName. I did a complete find/replace on the solution and changed the test project aswell. In Default.aspx.cs I get an InvalidOpterationException with

"The controller name 'Home' is ambiguous between the following types: MyNewProjectName.Controllers.HomeController MyProjectName.Controllers.HomeController."

How do i fix that? Thanks

6 Answers 6

33

Have you tried to rebuild (right click on project, and select "Rebuild")? Also check the bin to make sure only the assembly with the new name is there. Also, double check the project properties to verify the name of the assembly is outputted. If you're not sure what the name of the outputted assembly is, delete all the dlls from bin and rebuild.

Sign up to request clarification or add additional context in comments.

3 Comments

I did a rebuild and even a clean. I did a windows file search and apparently, VS didn't clear everything out.
This is annoying -- I just had the same issue. What a PITA. What is "clean" supposed to be doing???
I guess it removed files with project name, not all dlls.
8

You need to check your /bin folder in your MVC Web project, and either delete everything inside there and do a new build, or delete the old DLL (MyProjectName.dll).

The ASP.Net MVC runtime uses reflection to determine which controller a request must be passed to based on the routing information, and it is finding two Controllers that match the criteria (have the same name), and each is in a different assembly. That is why you get the exception.

Doing a Clean doesn't seem to clear out the bin folder. So you have to delete the file manually.

1 Comment

It's the old assemblies in the bin. Good call. +1
7

As for myself I had reference in web.config of the View folder, once it was changed everything worked fine!

1 Comment

This was my issue. I changed the Assembly and Namespace for my project and couldn't load a page. Updating the namespace entry in the Views web.config was the piece that was needed. Thanks!
2

Double click or right click on MyProject and open. In the application settings change the assembly name and root namespace to match your renamed project name.

Comments

0

Right-Click on the project, choose "Open Folder in Windows Explorer.

Delete the "OLDPROJECTNAME" objects in /bin and /obj

Comments

0

In my project I faced the same symptoms. To fixed that I had to:

  • Go to your App_Start and check if your new namespace is correct inside the classes.

  • Right click on Global.asax and go to "show markup" and check "Inherits" attribute has your new namespace.

Like:

<%@ Application Codebehind="Global.asax.cs" Inherits="MyNewNamespace.MvcApplication" Language="C#" %>

Rebuild the application.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.