Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems when trying to auto-generate the views for MVC3, from Controller's Action method

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

like image 655
bzamfir Avatar asked Dec 27 '22 12:12

bzamfir


2 Answers

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.

like image 131
amiry jd Avatar answered May 26 '23 13:05

amiry jd


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

like image 33
emilast Avatar answered May 26 '23 13:05

emilast