25

In Visual Studio 2013 in a fresh C# MVC 4 empty project I right click the controllers folder and select Add -> Controller... then select a name for the controller and click Add. I get the following error popup:

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ItemTemplates\CSharp\Web\MVC 4\CodeTemplates\AddController\Controller.tt(-1,-1): error: There was a problem getting an AppDomain to run the transformation from the host. The process cannot continue.

This also occurs when adding a view to the views folder using corresponding context menu option.

Question: what is the next step to troubleshoot this?

What I've tried so far:

Additional context:

  • Before I got this error I was able to successfully add multiple controllers and views without a problem. No visual studio restart or anything unusual happened between the successful and failed attempts.
  • I can go through the Add New Item dialogue and successfully add a controller or view, but the context menu Add -> Controller and Add -> View give the above error.
  • I have Visual Studio 2013 Update 4
  • Extensions I have added:
    • .net reflector,
    • attach to anything,
    • rename visual studio window title,
    • slowcheetah - xml transforms,
    • team foundation server power tools 2013,
    • visual studio 2013 color theme editor,
    • web essentials 2013 for update 4,
    • wix toolset
Community
  • 1
  • 1
MikeyT
  • 370
  • 5
  • 10
  • 5
    Have you tried to issue the cmd 'aspnet_regiis -I' again? Your Problem sounds a lot like a broken Installation of either VS or the IIS or a permissions issue. Have you altered the machine.config? Any difference using local IIS or IIS Express? – ovm Dec 26 '14 at 14:55
  • Thanks for your suggestion, but unfortunately (fortunately?) it started working again. After a couple of reboots and sleeps (normal usage) I decided to give it another try today and it magically worked. I don't know why the first reboot did not do the trick. I haven't changed anything with IIS or the machine.config. The site runs on IIS 7.5 (non express) by the way. – MikeyT Jan 05 '15 at 19:09
  • Ah, lovely. One of THOSE kind of errors. Guess I'll just wait and hope as well :( – Matt Sach Jan 30 '15 at 12:49
  • 1
    This error **often** occurs to me on a slow internet connection. I cannot deploy or update projects on anything less than 1mbps upload speed. – Ray Suelzer Mar 13 '15 at 20:19
  • Possibly a duplicate of: http://stackoverflow.com/questions/14637632/exception-when-adding-a-view-to-mvc3/ or http://stackoverflow.com/questions/14653039/error-when-creating-a-partial-view-in-visual-studio-2012-express-with-razor all though this one has more details, and none of them have a real "solution" beyond that it eventually works – Arkaine55 May 11 '15 at 01:01

4 Answers4

3

Additional things to check, as I've seen this happen before on Vista and newer operating systems:

  1. Owner of the IIS directory: If the owner of the IIS directory is different from the user running IIS and Visual Studio, it can cause issues, there are numerous scripts to take ownership of a directory, command lines you can run, or use the advanced security dialog.
  2. Permissions: Related to the problem with the owner above, I've had problems where the user running Visual Studio or IIS did not have appropriate permissions to access the directory or application pool.
  3. Running as Admin: I've had issues with IIS when not running Visual Studio as an admin, if you run Visual Studio as an admin, a lot of the issues related to the above two issues will resolve themselves, or go away completely; I'm aware this is not always an option to all developers.
Brian Deragon
  • 2,929
  • 24
  • 44
0

I would suggest following:

  1. Run Visual Studio in admin mode
  2. Try aspnet_regiis -I

I feel it's a permission issue.

mpromonet
  • 11,326
  • 43
  • 62
  • 91
Suraj D
  • 141
  • 1
  • 8
0

I just close visulstudio 2013 and reopen it in "Run as Administrator" mode. After that my problem solved and easily I added a view for the respective controller.

Sumit Ganguly
  • 69
  • 1
  • 3
-1

Have you checked in the .csproj file? I got a related (not exactly similar) issue when i started working on MVC for the first time, where i was not able to add View or Controller in VS2012 and i simply added the GUID {E3E379DF-F4C6-4180-9B81-6769533ABE47} and was able to add Views and Controllers.

Hope it helps resolve the problem!

Saruchi
  • 346
  • 2
  • 13
  • Why do u think this does not provide an answer??! This solution is tried and tested.. It would be great if u provide a reasonable comment for the down Vote!! http://www.mztools.com/articles/2008/mz2008017.aspx – Saruchi Jul 27 '15 at 07:32