We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Error when save a word file with comment

I create a word document by adding some html, which works fine, and I can save the document to Response like this

doc.Save("preview.doc", SaveFormat.Doc, SaveType.OpenInWord, Response);

but once I add some comment in like

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.InsertHtml("test html"));

Comment comment = new Comment(doc);
comment.Paragraphs.Add(new Paragraph(doc));
comment.FirstParagraph.Runs.Add(new Run(doc, "test"));

doc.Save("preview.doc", SaveFormat.Doc, SaveType.OpenInWord, Response);

it give me "Object reference not set to an instance of an object. "
any idea?

[NullReferenceException: Object reference not set to an instance of an object.]
ᓂ.ᠾ.ᡈ(String ՙ, BinaryWriter ࿌, Byte ᡇ) +28
ᓂ.᡻.࿋(BinaryWriter ࿌) +18
ᓂ.ឧ.࿋(BinaryWriter ࿌) +248
ᓂ.ᒨ.࿋(ᒡ ៾, BinaryWriter ᠥ) +145
⚤.⚣.⛉() +386
⚤.⚣.⚻() +118
⚤.⚣.⚺(⚚ ⚙) +48
Aspose.Words.Document.Save(String fileName, SaveFormat fileFormat, SaveType saveType, HttpResponse response) +745

Thanks for your inquiry. It is a known issue #4346. I will notify you as soon as it is fixed.
Best regards.

This is fixed in the next release that is coming out, but you can workaround now. Just set Comment.Author and Comment.Initial properties to non null values.

The issues you have found earlier (filed as 4346) have been fixed in this update.

The problem was caused by null author and initials. Changed defaults to empty strings.