what is and where can I find MvcTextTemplateHost

♀尐吖头ヾ 提交于 2019-12-01 19:29:01

MvcTextTemplateHost is "Host" of MVC 3.0 (Add>View and Add>Controller) Dialog and maintain user interactions:

so it is not available outside of the tool. When you provide "Scaffolding" template (a .tt file) a manager passes these user inputs to host so host will have those properties.

The class is packaged in: ($VSDIR)\Common7\IDE\Microsoft.VisualStudio.Web.Mvc.3.01.dll

Hope it helps.

Adalberto Rua

In my case the solution was. add these line en controllerWithContext.tt

<#@ assembly name="C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Microsoft.VisualStudio.Web.Mvc.3.01.dll" #>

next to:

<#@ import namespace="System.Reflection" #>

before:

<#@ import namespace="Microsoft.VisualStudio.Web.Mvc.Scaffolding.BuiltIn" #>

good luck

You can find all .tt files in VS installation direction, for example to get MVC4 .tt files, go to: ($VSDir)\Common7\IDE\ItemTemplates\CSharp\Web\MVC 4\CodeTemplates

To get the list of the properties of MvcTextTemplateHost, as they are dynamic, you can add the following code to your .tt file:

<#
Type myType = mvcHost.GetType();
IList<PropertyInfo> props = new List<PropertyInfo>(myType.GetProperties());

foreach (PropertyInfo prop in props)
{
#>
    <#= prop.Name #>
<#
}
#>

I ran it as I create a List View in MVC4, and some of the properties that came up are:

ViewName 
IsPartialView 
IsContentPage 
ReferenceScriptLibraries
AutoEventWireup 
MasterPageFile 
...
Chris Moschini

I had the same problem after installing the T4 templates for modifying Visual Studio's auto generated CRUD pages described in this question: How do I create my own Scaffold Template in ASP.NET MVC 3?

The solution for me was just to just close Visual Studio 2012 and say Yes to saving the solution. When I reopened it everything compiled fine again, magically. The comments on this answer suggest this has worked for similar situations: https://stackoverflow.com/a/13816299/176877

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!