4

When I try to create a view from action method of some controller (right click -> Add View -> select Strongly-typed view) I get the following error:


The templates had the following 2 error(s) when running:

c:\Users(...)\AppData\Local\Temp\b1b5zy30.0.cs(5,33) : error CS0234: Compiling transformation: The type or namespace name 'DataAnnotations' does not exist in the namespace 'System.ComponentModel' (are you missing an assembly reference?)

c:\Users(...)\AppData\Local\Temp\b1b5zy30.0.cs(6,23) : error CS0234: Compiling transformation: The type or namespace name 'Linq' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)


Does anyone knows what is going on? This worked a couple of days ago, and meantime I didn't made any changes to MVC installation

Thanks

bzamfir
  • 4,698
  • 10
  • 54
  • 89
  • Have you tried to apply the remedy suggested in the error messages i.e. add reference to System.ComponentModel and System.Data? – amit_g Oct 30 '11 at 03:52
  • Check this One, http://stackoverflow.com/questions/10174420/why-cant-i-reference-system-componentmodel-dataannotations – chalailama Apr 29 '12 at 17:39

2 Answers2

9

I got same error sometimes.

  • Go to c:\Users(...)\AppData\Local\Temp\ and delete .cs files in it.
  • Close VS and stop any server (if running -in try icon you'll see the servers that are running), go to %LocalAppData%\Temp\Temporary ASP.NET Files (by typing it Windows-Explorer's address-bar and Enter) and delete all file and folders there.
  • Go to %WINDIR%\Microsoft.NET\Framework\v(YOUR-VERSION)\Temporary ASP.NET Files and delete all files and folders there.
  • Clean and ReBuild entire solution.
  • Run it!

This steps should resolve the problem. Check it out.

amiry jd
  • 27,021
  • 30
  • 116
  • 215
  • this method didn't work for me, however uninstalling t4 as recommended by @emilast worked. – kolin Jul 16 '12 at 13:36
1

This error can occur after installing tangible T4 editor (http://t4-editor.tangible-engineering.com/T4-Editor-Visual-T4-Editing.html). Uninstalling it fixed the problem for me.

/Emil

emilast
  • 559
  • 1
  • 5
  • 11