Spark source data works initially, but after that you get the error "Dynamic view compilation error" after 30 minutes

After pushing my asp.net mvc project (with spark view) to our live server yesterday, I started getting a weird error. At first, everything worked fine, but after a while (maybe 30 minutes), the views start throwing errors "Compile with dynamic view" and complain about non-existent namespaces. The fees for the namespaces he listed are in the bunker (since it really worked at the initial stage). I use the spark vision mechanism on other websites running on the same field and have never seen this problem. What makes these views stop working?

+4
source share
1 answer

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); //Whatever else you normally do in Application_Start(): MvcHandler.DisableMvcResponseHeader = true; ViewEngineManager.Configure(ViewEngines.Engines); RouteManager.RegisterRoutes(RouteTable.Routes); new InjectionManager().StartNinject(); } 
+5
source

All Articles