Dynamic view compilation failed only after app recycle

175 views
Skip to first unread message

karl

unread,
Sep 6, 2009, 1:10:04 PM9/6/09
to Spark View Engine Dev
I'm getting a consistent problem with both the 1.0 and trunk. Whenever
the app pool recycles, the spark compiler doesn't seem to load all of
my referenced assemblies, resulting in compilation errors. This is
happening across two different projects.

The best way to reproduce this is to grab the CodeBetter.Canvas
project from:
http://code.google.com/p/codebettercanvas/source/checkout

Open it in VS.NET, put it in release mode (this may or may not be
necessary) and launch the application. Go to the login page (again,
possibly un-necessary). Touch the web.config (causing an app recycle)
and hit refresh.

You will hopefully see that MvcContrib could not be found.

Help :)

Karl

Louis DeJardin

unread,
Sep 6, 2009, 3:11:11 PM9/6/09
to spar...@googlegroups.com
That's probably from what you could call a design flaw in the
compiler. It's using all of the assemblies loaded in the current app
domain, but that can cause race conditions sometimes when an app
domain first loads.

Try adding the assembly references exlicitly in the _global.spark, or
the <spark> web.config section or SparkSettings object. Or try
assembly.load of the dependencies in the app start.

Chad Lee

unread,
Sep 6, 2009, 4:06:01 PM9/6/09
to spar...@googlegroups.com
I've had that same problem before.  I ended up resolving it with this code in Application_OnStart:

Assembly[] initialAssemblies = AppDomain.CurrentDomain.GetAssemblies();

DirectoryInfo di = new DirectoryInfo(Server.MapPath("~/bin"));
FileInfo[] files = di.GetFiles("*.dll");
foreach (FileInfo fi in files)
{
bool found = false;

//already loaded?
foreach (Assembly ass in initialAssemblies)
{
Assembly a = Assembly.ReflectionOnlyLoadFrom(fi.FullName);
if (ass.FullName == a.FullName)
found = true;
}

if (!found)
Assembly.LoadFrom(fi.FullName);
}

It just loads all assemblies in the bin directory into the current app domain before spark has chance to compile any views.

David R. Longnecker

unread,
Oct 4, 2009, 5:13:24 PM10/4/09
to spar...@googlegroups.com
Figured to bump this before I wander off to beat my head on a wall.

As others have mentioned, I'm experiencing the same issues; however, Chad's preloading of assemblies still seems to flake out on my hosted provided (WebHost4Life).  I've attempted to add everything to _global.spark and that's prevented the error from occurring locally; but 1/3rd of the time, it still fails remotely--which is a bugger to fix (reload the web.config remotely or wait for it to cycle).

I even tried including ALL .NET references in ~/bin so they'd be picked up by the Assembly loading method--no dice.

I'm currently in the process of trimming down EVERYTHING called by the templates and _global.spark, but if anyone has dinged a miracle, I'm all ears. :)

TIA!

-dl

--
David R. Longnecker
blog: http://blog.tiredstudent.com
twitter: dlongnecker

"Good design is a Renaissance attitude that combines technology, cognitive science, human need, and beauty to produce something." - Paola Antonelli
Reply all
Reply to author
Forward
0 new messages