I have a problem that I can't solve for quite a while now. I need a page that uses XslCompiledTransform and has quite enormous hit count.
In order to avoid recompiling of the xsl, I would like to keep the XslCompiledTransform in global.asax and reference it from the codebehind of the page I'm using.
The code I wrote seems to work just fine in debug/non-published configurations, but throws null reference exception when published.
<%@ Application Language="VB" %>
<object id="transformer" runat="server" scope="application" class="System.Xml.Xsl.XslCompiledTransform" />
<script runat="server">
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application startup
'System.Diagnostics.Debugger.Break()
Try
transformer.Load(Server.MapPath("ssheet.xsl"), System.Xml.Xsl.XsltSettings.TrustedXslt, Nothing)
System.Diagnostics.Debugger.Break()
System.Threading.Thread.Sleep(1000)
Catch ex As Exception
System.Diagnostics.Debugger.Break()
System.Threading.Thread.Sleep(1000)
End Try
System.Diagnostics.Debugger.Break()
System.Threading.Thread.Sleep(1000)
Application("transformer") = transformer
End Sub
and I'm accessing the transformer like this
Dim transformer As Xsl.XslCompiledTransform = Application("transformer")
EDIT: When I managed to break into debugger, I couldn't see the troubling code because of 'the code is optimized'