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

Free Support Forum - aspose.com

System.NullReferenceException exception in Aspose.Words.Document.Save

We have started getting a NullReferenceException when trying to save a generated document. The document is comprised of data from our system, and also optionally combines in several sub documents. All the documents have only been edited in MS Word, so we do not think they are corrupt.
Exception information:

System.NullReferenceException: Object reference not set to an
instance of an object.<o:p></o:p>

at ෶..(String ՗, BinaryWriter , Byte )

at ෶.ᝄ.ೝ(BinaryWriter )

at ෶.ᚓ.ೝ(BinaryWriter )

at ෶.ᐰ.ೝ(ᐩ ᛨ, BinaryWriter ᜍ)

at ..()

at ..()

at ..( )

at Aspose.Words.Document.ࠎ(Stream ؟, String ؖ, SaveFormat ࠏ)

at Aspose.Words.Document.Save(String fileName, SaveFormat fileFormat)

at Aspose.Words.Document.Save(String fileName)



Hello!

Thank you for your interest in Aspose components.

Please attach the problematic document so we could reproduce and spot this issue.

In what format are you saving - DOC?

Regards,

It’s taken me some time to reproduce this in a simple way, without shipping a million lines of code, and a 4Gb database :-).

The simpliest code sample to reproduce this on the latest release (4.4.2.0) is below:

using Aspose.Words;

namespace AsposeCrash
{
class Program
{
static void Main(string[] args) {
Document _doc = new Document();
DocumentBuilder _builder = new DocumentBuilder(_doc);
Table _t = _builder.StartTable();
Cell _c1 = _builder.InsertCell();
Paragraph _cellParagraph = _builder.InsertParagraph();

Comment _comment = new Comment(_doc);
_comment.Author = “Author”;
Paragraph _commentParagraph = new Paragraph(_doc);
_comment.Paragraphs.Add(_commentParagraph);
_commentParagraph.Runs.Add(new Run(_doc, “Test”));

_cellParagraph.AppendChild(_comment);

Cell _c2 = _builder.InsertCell();
_builder.EndRow();
Cell _c3 = _builder.InsertCell();
Cell _c4 = _builder.InsertCell();
_builder.EndRow();
_builder.EndTable();
_doc.Save(@“c:\temp\crash.doc”);


}
}
}

This code works fine with the previous version we were using 4.2.6.0.



Hello Tim.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for your help. I have reproduced this exception with Aspose.Words 4.4.2.0 and logged as #4125 in our defect database. It’s a severe issue (crash) and we’ll definitely try to fix it in the next release, approximately 1-2 weeks. We’ll notify you when it is available.

Best regards,

Hi,
I notice that there is a new version available (4.4.3), if doesn’t mention that this issue is fixed in the notes. Can you tell me if it is fixed in this release, or if not give me an idea of when it will be fixed.

Thanks,

Tim

Hello Tim.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I’m sorry. #4125 hasn’t been fixed in Aspose.Words 4.4.3.0. The issue is still open. We’ll try to include the fix in the next release closer to the end of January. If it is urgent maybe we can transform your code somehow to avoid the exception.

Regards,

The issues you have found earlier (filed as 4125) have been fixed in this update.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />