Question

Just getting started on NVelocity (v1.1.1) and it seems to be working just fine.

There's just one small thing that annoys me. I've set up VS2010 to break each time an exception is thrown even though it gets handled somewhere, and when running the following code, it always breaks at the call to Evaluate, stating that it "Cannot read from a closed TextReader" (ObjectDisposedException). I do not have the source code for NVelocity, so I cannot debug.

Am I missing a setting somewhere that causes this? Is it just a harmless bug in NVelocity? The result comes out fine, to me it just seems like something's not quite right.

var velocity = new VelocityEngine();
var properties = new ExtendedProperties();
var context = new VelocityContext(fieldValues);
properties.AddProperty("velocimacro.library", string.Empty); // no library
velocity.Init(properties);

using (var writer = new StringWriter())
{
  velocity.Evaluate(context, writer, null, templateContents);
  return writer.ToString();
}

Exception stack trace:

at System.IO.__Error.ReaderClosed() at System.IO.StringReader.Read(Char[] buffer, Int32 index, Int32 count)
at NVelocity.Runtime.Parser.VelocityCharStream.FillBuff() in c:\...\src\NVelocity\Runtime\Parser\VelocityCharStream.cs:line 313

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top