刚刚开始使用NVelocity (v1.1.1),它似乎运行得很好。
只有一件小事让我恼火。我将VS2010设置为每次抛出异常时,即使它在某个地方被处理,并且在运行下面的代码时,它总是在要计算的调用时中断,声明它“不能从封闭的TextReader (ObjectDisposedException)中读取”。我没有NVelocity的源代码,所以我无法调试。
我是不是错过了一个导致这一切的环境?在NVelocity中,它只是一个无害的bug吗?结果很好,对我来说似乎有些不太对劲。
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();
}异常堆栈跟踪:
在System.IO.__Error.ReaderClosed() at System.IO.StringReader.Read(Char[]缓冲器,Int32索引,Int32计数) 在NVelocity.Runtime.Parser.VelocityCharStream.FillBuff() ( c:...\src\NVelocity\Runtime\Parser\VelocityCharStream.cs:line 313 )
发布于 2012-03-15 13:34:51
这是一个第一次例外。你可以在源代码中看到此异常是在NVelocity代码中捕获的。。
https://stackoverflow.com/questions/9718339
复制相似问题