我一直在使用 XslCompiledTransform 因为微软告诉我我需要使用 XslTransform 已被弃用。<ExactDatetime>200-02-02</ExactDatetime> ) 使用 XslTransform<ExactDatetime>200-02-02</ExactDatetime> ) 使用 XslCompiledTransform 失败<ExactDatetime></ExactDatetime> ) 使用 XslTransform
作品:

XslTransform xslDoc = new XslTransform();
xslDoc.Load(xslPath);
xslDoc.Transform(doc, Response.Output);
JIT 失败(使用日期示例 200-02-02 时)
XslCompiledTransform xslDoc = new XslCompiledTransform();
xslDoc.Load(xslPath);
xslDoc.Transform(doc, new XmlTextWriter(Response.Output));
JIT 编译器遇到内部限制。

源错误:
Line 33:            //xslDoc.Transform(doc, Response.Output);
Line 34:
Line 35:             xslDoc.Transform(doc, new XmlTextWriter(Response.Output));
Line 36:         }
Line 37:   }
源文件:c:\shahid\ccr_test\test1\Default.aspx.cs 行:35
堆栈跟踪:
[InvalidProgramException: JIT Compiler encountered an internal limitation.]
   <xsl:template name="date:_format-date">(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, IList`1 year, IList`1 month, IList`1 day, IList`1 hour, IList`1 minute, IList`1 second, IList`1 timezone, IList`1 pattern) +0
   <xsl:template name="date:format-date">(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator date-time, XPathNavigator pattern) +5170
   <xsl:template match="DateTime" name="dateTime">(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-debug}current, IList`1 dt, XPathNavigator fmt) +12397
   <xsl:template match="/">(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-debug}current) +46057
   Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) +91
   Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) +28
   System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter results) +88
   System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer, Boolean closeWriter) +193
   System.Xml.Xsl.XmlILCommand.Execute(XmlReader contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter results) +28
   System.Xml.Xsl.XslCompiledTransform.Transform(String inputUri, XmlWriter results) +81
   _Default.Button1_Click(Object sender, EventArgs e) in c:\shahid\ccr_test\test1\Default.aspx.cs:35
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

最佳答案

我有同样的问题,我认为它是相同的样式表(CCR)。

问题是编译后的 XSLT 拒绝访问 document() 函数,并且没有正确处理错误。在 XslCompiledTransform.Load() 调用中,传入允许使用文档功能的 XsltSettings 对象。像这样的东西:

myTransform.Load(filename,XsltSettings.TrustedXslt,new XmlUrlResolver());

关于c# - JIT 编译器遇到内部限制。 VS2008,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/1557664/

10-15 19:54