Exception "Object reference not set to an instance of an object" calling document.Save(...)

I’m getting an “Object reference not set to an instance of an object” exception when calling document.Save()

Code:

ComponentInfo.SetLicense(ImportUtils.gemBoxSerialKey);
ComponentInfo.FreeLimitReached += (sender, e) => e.FreeLimitReachedAction = FreeLimitReachedAction.ContinueAsTrial;

var document = DocumentModel.Load(uploadedFilePath);

CapturerByText capturer = new CapturerByText(document, null);

// Convert the document to HTML string
var saveOptions = new HtmlSaveOptions()
{
    HtmlType = HtmlType.HtmlInline,
    EmbedImages = true,
    UseSemanticElements = false
};

string htmlName = $"{Guid.NewGuid()}_Exported.html";

// Save DocumentModel object to HTML (or MHTML) file.
document.Save(htmlName, saveOptions);

Exception: Object reference not set to an instance of an object.

Stacktrace:

Hi Mirel,

I was unable to reproduce this issue.
Just in case, can you please try again with the latest version:

If the problem persists, please send us a small Visual Studio project (along with the “uploadedFilePath” input file) that reproduces the issue so we can investigate it. You can send it via email or support ticket (see the Contact page).

Regards,
Mario