运行时模板具有以下错误

时间:2013-05-21 09:16:28

标签: c# asp.net-mvc visual-studio t4 strongly-typed-view

当我尝试在ASP.NET MVC 3中添加强类型视图时,出现以下错误:

The templates had the following 4 errors when running

我重新启动Visual Studio,重建项目,再次尝试添加视图并获得以下内容: The templates had the following 2 errors when running

我的模特:

public class SimpleModel
{
    public int ID { get; set; }
    public string Name { get; set; }
    public bool IsActive { get; set; }
}

我的控制器:

public class TestController : Controller
{
    public ActionResult Test()
    {
        return View(new SimpleModel());
    }
}

问题在于整个环境(我创建了一个新项目并试图添加一个视图,结果相同),并且无法通过重新启动Visual Studio或我的开发机器来解决。 编辑:只需重新安装ASP.NET和Web Tools 2012.2即可解决问题。

1 个答案:

答案 0 :(得分:0)

使用process monitor,我发现,至少在我的机器上,Visual Studio从GAC加载System.ComponentModel.DataAnnotations.dll

  

12:43:12.6470833 PM devenv.exe 772加载图像C:\ Windows \ Microsoft.NET \ assembly \ GAC_MSIL \ System.ComponentModel.DataAnnotations \ v4.0_4.0.0.0__31bf3856ad364e35 \ System.ComponentModel.DataAnnotations.dll SUCCESS图像库:0x5f7b0000,图像大小:0x1e000

我做的是我已启动进程监视器,添加过滤器以仅从devenv.exe捕获事件,然后尝试为MVC 3应用程序构建视图,然后在捕获的事件中搜索System.ComponentModel.DataAnnotations.dll

相关问题