I would like to know what this is MvcTextTemplateHost. I have this in my create.tt but I cant find it in my bin folder (searching with object viewer). I read up and found ou
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
...
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
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.
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