开发者

what is and where can I find MvcTextTemplateHost

开发者 https://www.devze.com 2023-03-12 13:14 出处:网络
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 out it\'s in

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 out it's in my VisualStudio.Extensions.web.dll but I cant find this dll

I've read this

T4 References for 'MvcTextTemplateHost' and 'VisualStudio'.

I would just like to know what properties and methods this class has. I would love a t4 text editor. I installed a few but nothing gives me intellisense for this class thank you.


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.


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 
...


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

0

精彩评论

暂无评论...
验证码 换一张
取 消