[Mono-list] HttpRuntime initialised check?

James Fitzsimons james.fitzsimons at gmail.com
Tue Aug 14 16:49:04 EDT 2007

Hi all,

I am doing a bit of work trying to get Spring.NET (specifically the web
support) running on mono. I am using 1.2.5 preview 3 of the mono runtime
at the moment.

The problem is that in the spring code they attempt to check if the
HttpRuntime has been fully initialised. They do this in a rather nasty
fashion that will only ever work on the MS .NET runtime. The question I
have for this list is:

Is there a "correct" way to check if the HttpRuntime has finished it's

From this http://msdn2.microsoft.com/en-us/library/aa479328.aspx

"The HttpRuntime object initializes a number of internal objects that
will help carry the request out. Helper objects include the cache
manager (the Cache object) and the internal file system monitor used to
detect changes in the source files that form the application. The
HttpRuntime creates the context for the request and fills it up with any
HTTP information specific to the request. The context is represented by
an instance of the HttpContext class."

it looks like you could just check if the HttpContext wasn't null. Would
that be a sufficient check?

Thanks for any advice you can provide!
James Fitzsimons

PS: offending Spring.NET code here:

 static WebApplicationContext()
        // register for ContextRegistry.Cleared event - we need to
discard our cache in this case
        ContextRegistry.Cleared += new

#if NET_2_0
        if (HttpRuntime.AppDomainAppVirtualPath != null) // check if
we're within an ASP.NET AppDomain!
            // ensure HttpRuntime has been fully initialized!
            // this is a problem,.if ASP.NET Web Administration
Application is used. This app does not fully set up the AppDomain...
            HttpRuntime runtime =
BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);

            bool beforeFirstRequest = false;
            lock (HttpRuntime)
                beforeFirstRequest =
BindingFlags.Instance | BindingFlags.NonPublic).
            log.Debug("BeforeFirstRequest:" + beforeFirstRequest);
            if (beforeFirstRequest)
                    string firstRequestPath =
HttpRuntime.AppDomainAppVirtualPath.TrimEnd('/') + "/dummy.context";
                    log.Info("Forcing first request " +
                        new SimpleWorkerRequest(firstRequestPath,
string.Empty, new StringWriter()));
                    log.Info("Successfully processed first request!");
                catch (Exception ex)
                    log.Error("Failed processing first request", ex);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.ximian.com/pipermail/mono-list/attachments/20070814/db9f5000/attachment.bin 

More information about the Mono-list mailing list