As qstarin noted, re-disposing of AppPool seems to crowd out assemblies. Here's the original Spark discussion on the issue:
http://groups.google.com/group/spark-dev/browse_thread/thread/dbee06a0d1b2766f#
In general, the problem seems to be caused by Spark trying to compile the views before AppPool has managed to load all the assemblies.
Choosing assemblies one after another still caused me random crashes, so I changed the code in this discussion and loaded it as the first line in Application_Start (). Since then, I have crowded out dozens or so of applications over time and have not seen a problem with precompilation.
private void PreLoadAssemblies() { // Deal with the compiling issue with Spark. var initialAssemblies = AppDomain.CurrentDomain.GetAssemblies(); var di = new DirectoryInfo(Server.MapPath("~/bin")); var files = di.GetFiles("*.dll"); foreach (var fi in files) { var found = false; //already loaded? foreach (var asm in initialAssemblies) { var a = Assembly.ReflectionOnlyLoadFrom(fi.FullName); if (asm.FullName == a.FullName) found = true; } if (!found) Assembly.LoadFrom(fi.FullName); } }
and then your Application_Start ():
protected override void Application_Start(object sender, EventArgs e) { PreLoadAssemblies(); base.Application_Start(sender, e);
source share