Sign in to follow this  
_Madman_

[web] Functions in Global.asax

Recommended Posts

_Madman_    100
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'

Share this post


Link to post
Share on other sites
_Madman_    100
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this