【发布时间】:2012-07-07 20:03:45
【问题描述】:
我一直在使用 itextsharp,它运行良好,直到我将编辑器更改为 Telerik MVC 编辑器,如果我输入特殊字符,例如 < 或 >,我会收到以下错误:
对象引用未设置为对象的实例。
我的程序的工作方式是使用以下脚本从 SQL Server 表中读取建议列表:
string BPRecommendation = "<span style='font-size:10;'>";
for (int i = 0; i < this.selectedVisit.Recommendations.Count; i++)
{
if (i > 0) BPRecommendation += "<br />";
BPRecommendation += this.selectedVisit.Recommendations[i].FullName +
" (" + this.selectedVisit.Recommendations[i].UserType + "):<br />";
BPRecommendation += this.selectedVisit.Recommendations[i].Comments +
".<br /><br />";
}
BPRecommendation += "</span>";
List<IElement> htmlarraylist = iTextSharp.text.html.simpleparser.HTMLWorker
.ParseToList(new StringReader(BPRecommendation), null);
//add the collection to the document
for (int k = 0; k < htmlarraylist.Count; k++)
{
paragraph.Add((IElement)htmlarraylist[k]);
}
doc.Add(paragraph);
【问题讨论】:
-
哪一行导致异常?使用您的调试器找出 哪个 变量为空。
-
是htmlarraylist。如果我从它起作用的文本中删除
标签: c# asp.net-mvc itextsharp telerik-mvc