Licence use provoke : System.NullReferenceException when calling document.save()

Hi,

I use aspose.words, we just get the licence. now when I try to use the licence, i throws a nul exception when saving the file.

But it works when not using the licence (but troncated)

System.NullReferenceException: Object reference not set to an instance of an object.
at ՛.℺.⅁(ShapeBase ೣ)
at ՛.℺.VisitShapeStart(Shape shape)
at Aspose.Words.Drawing.Shape.Accept(DocumentVisitor visitor)
at Aspose.Words.CompositeNode.ނ(DocumentVisitor ރ)
at Aspose.Words.Paragraph.Accept(DocumentVisitor visitor)
at Aspose.Words.CompositeNode.ނ(DocumentVisitor ރ)
at Aspose.Words.Body.Accept(DocumentVisitor visitor)
at Aspose.Words.CompositeNode.ނ(DocumentVisitor ރ)
at Aspose.Words.Section.Accept(DocumentVisitor visitor)
at Aspose.Words.CompositeNode.ނ(DocumentVisitor ރ)
at Aspose.Words.Document.Accept(DocumentVisitor visitor)
at Aspose.Words.Document.Save(String fileName, SaveFormat fileFormat)
at Aspose.Words.Document.Save(String fileName)
at PG.DataSourcesParser.ParseConfig(Dictionary`2 ParamsMOD, Dictionary`2 Params, String che, MySqlConnection connection)


And no exception is thrown when using the licence. Do you have any idea?

Thanks

Hi,

Very strange. There shouldn't be any relationship between setting the license and save failure. Please attach the problematic document to your post here.

Thanks for replying quickly, our applciation is quite big and I reported mu error in one file to focus on my problem.

if we remove the //, the following code doesn't work any longer, a exception is thrown on save()..

//Aspose.Words.License license = new Aspose.Words.License(); (*)

//license.SetLicense("Aspose.Words.lic"); (*)

Document doc = new Document("C:\\ASPOSE_TEST\\exp.doc");

DocumentBuilder builder = new DocumentBuilder(doc);

builder.MoveToBookmark("TITLE_AppShortName");

builder.InsertHtml("mytest");

doc.Save("C:\\ASPOSE_TEST\\mytest.doc");

Exception :

at ՛.℺.⅁(ShapeBase ೣ)
at ՛.℺.VisitShapeStart(Shape shape)
at Aspose.Words.Drawing.Shape.Accept(DocumentVisitor visitor)
at Aspose.Words.CompositeNode.ނ(DocumentVisitor ރ)
at Aspose.Words.Paragraph.Accept(DocumentVisitor visitor)
at Aspose.Words.CompositeNode.ނ(DocumentVisitor ރ)
at Aspose.Words.Body.Accept(DocumentVisitor visitor)
at Aspose.Words.CompositeNode.ނ(DocumentVisitor ރ)
at Aspose.Words.Section.Accept(DocumentVisitor visitor)
at Aspose.Words.CompositeNode.ނ(DocumentVisitor ރ)
at Aspose.Words.Document.Accept(DocumentVisitor visitor)
at Aspose.Words.Document.Save(String fileName, SaveFormat fileFormat)
at Aspose.Words.Document.Save(String fileName)
at PG.DataSourcesParser.ParseConfig(Dictionary`2 ParamsMOD, Dictionary`2 Params, String che, MySqlConnection connection)

Note : for the lines (*) if licence is not seen, an exception is thrown, so we can say that licence is correctly found

What's wrong with this code, we forgot something with using licence?

Thanks

Your code looks absolutely correct. Could you please also attach the document to test?

using System;

using System.Collections.Generic;

using Aspose.Words;

using Aspose.Words.Drawing;

namespace testaspose

{

class MainClass

{

public static void Main(string[] args)

{

Aspose.Words.License license = new Aspose.Words.License();

license.SetLicense("Aspose.Words.lic");

Document doc = new Document("C:\\ASPOSE_TEST\\exp.doc");

DocumentBuilder builder = new DocumentBuilder(doc);

builder.MoveToBookmark("TITLE_AppShortName");

builder.InsertHtml("mytest");

doc.Save("C:\\ASPOSE_TEST\\mytest.doc");

}

}

}

The doc file used is attached

I have tested your document and everything worked perfectly, both with a license or without. Please try to do the following:

  1. Upgrade to the latest version of Aspose.Words (4.0.4) and try it.
  2. If it does not help, send me your license file as you suggested in the private message. You can simply attach it to your post here as your attachments are only visible to you and Aspose staff, no one else.

Change from 4.0.1 to 4.0.4 dll version made it working. Thanks for all these fast answers!

best regards

Bye