T4模版生成问题
同在应用T4动态生成,自定义好的格式内容。当做模板来应用
项目情况:Web MVC ,在Server2003|08服务
在测试服务器,及本地都是良好,能够正常生成内容(都有装Vs开发工具)。
正确结果为:
在正网服务器生成出来的是过程代码,如下代码所示:
服务器上面(2008),没有装Vs工具,但是对应环境都是有的!Web动态生成,产生的结果就如上图所示, 但是非常奇怪的一点就是,非常搞不懂的地方?Winform程序,生成完完全全OK。郁闷中
大家谁有遇见前来指点一下。
参考MSDN文章 ,多实一下ITextTemplatingSessionHost用于参数传递
这是程序源码
下载地址如下:http://files.cnblogs.com/yhongl/WebApplicationOfConsole.rar
项目情况:Web MVC ,在Server2003|08服务
在测试服务器,及本地都是良好,能够正常生成内容(都有装Vs开发工具)。
正确结果为:
标题:
现在处理时间:2014/11/18 10:07:49
<br/>
内容:
DataOfIO
在正网服务器生成出来的是过程代码,如下代码所示:
namespace Microsoft.VisualStudio.TextTemplating3D1E5FBD650A2E73E9BADA6E7FDD272E
{
using System;
using System.Text;
using System.Collections.Generic;
using WebApplicationOfConsole;
#line 1 "ea_performance_settle_report.tt"
public class GeneratedTextTransformation : Microsoft.VisualStudio.TextTemplating.TextTransformation
{
public override string TransformText()
{
try
{
this.Write("\r\n");
this.Write("\r\n标题:\r\n");
#line 11 "ea_performance_settle_report.tt"
this.Write(Microsoft.VisualStudio.TextTemplating.ToStringHelper.ToStringWithCulture(paramData.Title));
#line default
#line hidden
this.Write("\r\n<br/>\r\n内容:\r\n");
#line 14 "ea_performance_settle_report.tt"
this.Write(Microsoft.VisualStudio.TextTemplating.ToStringHelper.ToStringWithCulture(paramData.Data));
#line default
#line hidden
this.Write("\r\n \r\n");
}
catch (System.Exception e)
{
e.Data["TextTemplatingProgress"] = this.GenerationEnvironment.ToString();
throw;
}
return this.GenerationEnvironment.ToString();
}
#line 1 "ea_performance_settle_report.tt"
private global::WebApplicationOfConsole.PerformanceData _paramDataField;
/// <summary>
/// Access the paramData parameter of the template.
/// </summary>
private global::WebApplicationOfConsole.PerformanceData paramData
{
get
{
return this._paramDataField;
}
}
public override void Initialize()
{
base.Initialize();
if ((this.Errors.HasErrors == false))
{
bool paramDataValueAcquired = false;
if (this.Session.ContainsKey("paramData"))
{
if ((typeof(global::WebApplicationOfConsole.PerformanceData).IsAssignableFrom(this.Session["paramData"].GetType()) == false))
{
this.Error("The type \'WebApplicationOfConsole.PerformanceData\' of the parameter \'paramData\' d" +
"id not match the type of the data passed to the template.");
}
else
{
this._paramDataField = ((global::WebApplicationOfConsole.PerformanceData)(this.Session["paramData"]));
paramDataValueAcquired = true;
}
}
if ((paramDataValueAcquired == false))
{
object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("paramData");
if ((data != null))
{
if ((typeof(global::WebApplicationOfConsole.PerformanceData).IsAssignableFrom(data.GetType()) == false))
{
this.Error("The type \'WebApplicationOfConsole.PerformanceData\' of the parameter \'paramData\' d" +
"id not match the type of the data passed to the template.");
}
else
{
this._paramDataField = ((global::WebApplicationOfConsole.PerformanceData)(data));
}
}
}
}
}
#line default
#line hidden
}
#line default
#line hidden
}
服务器上面(2008),没有装Vs工具,但是对应环境都是有的!Web动态生成,产生的结果就如上图所示, 但是非常奇怪的一点就是,非常搞不懂的地方?Winform程序,生成完完全全OK。郁闷中
大家谁有遇见前来指点一下。
参考MSDN文章 ,多实一下ITextTemplatingSessionHost用于参数传递
这是程序源码
下载地址如下:http://files.cnblogs.com/yhongl/WebApplicationOfConsole.rar
...全文


