[web] Functions in Global.asax

Started by
0 comments, last by _Madman_ 17 years, 5 months ago
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'
______________________________Madman
Advertisement
I finally found the solution here: http://www.eps-publications.com/articleprint.aspx?quickid=0403021&page=2&printmode=true

It turns out MS has (I'd qualify it as a bug) mistake in their deployment module. Global.asax is not precompiled in same dll's that regular pages are and it has to be deployed along with the other files. MS tool doesn't do that.
______________________________Madman

This topic is closed to new replies.

Advertisement