1

刚刚开始使用 NVelocity (v1.1.1),它似乎工作得很好。

只有一件小事让我很恼火。我已经将 VS2010 设置为在每次引发异常时中断,即使它在某处得到处理,并且在运行以下代码时,它总是在调用 Evaluate 时中断,说明它“无法从关闭的 TextReader 读取”(ObjectDisposedException )。我没有 NVelocity 的源代码,所以我无法调试。

我是否错过了导致此问题的某个设置?它只是 NVelocity 中的一个无害错误吗?结果很好,对我来说似乎有些不太对劲。

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() 在 System.IO.StringReader.Read(Char[] buffer, Int32 index, Int32 count)
在 NVelocity.Runtime.Parser.VelocityCharStream.FillBuff() 在 c:\...\ src\NVelocity\Runtime\Parser\VelocityCharStream.cs:第 313 行

4

1 回答 1

2

这是第一次机会例外。您可以在源代码中看到,此异常随后在 NVelocity 代码中被捕获

于 2012-03-15T13:34:51.640 回答