This issue has been reported to Microsoft over and over without them offering much of a solution:
Some workarounds suggested by various Developers are as follows:
- You can also create a new solution in VS2012, then import all of the existing code files from the original solution. Add => Controller... will then start functioning properly again.
- Select Add => New Item from the context menu, then choose MVC 4 Controller. However, you don't get any of the scaffolding that you do with the wizard.
- Run devenv.exe /resetskippkgs http://msdn.microsoft.com/en-us/library/ms241276(v=vs.100).aspx
- Disable "Visual Studio Hosting Process" in each executable project's properties (build tab, all the way at the bottom)
- Disable Intellitrace on Debug in Tools, Options, Intellitrace
None of the above solutions however address the actual reason that causes this problem, and no it is not a Visual Studio bug but an Operating System behavior that causes this issue. The issue is caused by the Automatic File Block feature that was adding by Microsoft in recent years. Basically, any time you download or copy files and/or folders from the web or an un-trusted source Windows automatically blocks that file or folder. If you right click on the file in question, you will see the following:
Here is a list of ways your file may get blocked:
- Your Project is under CVS, SVN, Git or Mercurial Source Control, and you just fetched the latest version of the Project from that Source Control.
- You downloaded the project from the WWW through a list file and extracted it, then ran the Solution File.
- You copied the files from a Network Location that is NOT Trusted by your PC.
All you have to do to unblock the files and folders is to click on the "Unblock" button shown in this dialog, which you can get to by right-clicking on the file and choosing "Properties" in File Explorer. Ideally you want to unblock all files and folders in your project, but the important ones are:
- /packages/EntityFramework.5.0.0 (or whatever version you are using) recursively
- Your Project's ".sln", ".suo", ".v11.suo", ".csproj", ".csproj.user".
- All assemblies inside the "bin" folder.
- The "Controllers" folder and all Controller Class files inside it.
Make sure Visual Studio is closed and exited completely before doing this. By doing so you should be able to Add Controllers in the above manner again.
Comments, suggestions, concerns? Leave them down below.
DigiOz Multimedia, Inc.