T4模版生成问题

大Y 2014-11-18 10:00:20
同在应用T4动态生成,自定义好的格式内容。当做模板来应用
项目情况: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
...全文
163 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧