Free Support Forum - aspose.com

Unable to open document Onenote 2016

Aspose.Note 2.3.0
Visual Studio 2017
Windows server 2016

Code not very difficult.

namespace TestOnenote
{
class Program
{

    static void Main(string[] args)
    {
        Aspose.Note.License asposeLic = new Aspose.Note.License();
        FileStream asposeStream = new FileStream("Aspose.Total.lic", FileMode.Open);
        asposeLic.SetLicense(asposeStream);

        Document doc = null;          

        try
        {
            doc =  new Document(@"d:\temp\meetings.one");
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            throw;
        }

        Console.Write("Press any enter to finish");
        Console.ReadLine(); ;

    }
}

}

Error:

D:\test\testWorkDay\TestOnenote\bin\Release>TestOnenote.exe
The type initializer for ‘??’ threw an exception.

Unhandled Exception: System.TypeInitializationException: The type initializer for ‘??’ threw an exception. —> System.IO.InvalidDataException: It seems stream contains non TrueType font. —> System.IO.InvalidDataException: It seems stream contains non TrueType font.
at Aspose.Note.Fonts.FontsSubsystem.(Stream )
— End of inner exception stack trace —
at Aspose.Note.Fonts.FontsSubsystem.(Stream )
at Aspose.Note.Fonts.FontsSubsystem…ctor(Stream defaultFont, Dictionary`2 fontsSubstitutions)
at ??..ctor()
at ??..cctor()
— End of inner exception stack trace —
at ??.()
at Aspose.Note.Page…ctor(Document document)
at ?.? ? ()
at ?.? ? ()
at ?.()
at ?.? ? ()
at ?.(Stream , Document , LoadOptions )
at Aspose.Note.Document.(String , LoadOptions )
at Aspose.Note.Document…ctor(String filePath, LoadOptions loadOptions)
at Aspose.Note.Document…ctor(String filePath)
at TestOnenote.Program.Main(String[] args) in D:\test\testWorkDay\TestOnenote\Program.cs:line 35

D:\test\testWorkDay\TestOnenote\bin\Release>

@PhHElia,

Please try our latest version/fix: Aspose.Note for .NET 21.3:

We have enhanced reading OneNote 2016 documents feature in newer versions.

If you still find the issue with latest version, kindly zip the file and post us here, we will check it soon.

It’s already this version used to test.

Here the file used for test
Meetings.zip (49.5 KB)

@PhHElia,

I did test your scenario/ case using your provided document and found it works fine. Aspose.Note for .NET v21.3 reads the one note document fine. I am using the following line of code to evaluate your issue:
e.g.
Sample code:

Aspose.Note.Document doc = new Aspose.Note.Document("E:\\test2\\meetings.one");
Console.WriteLine("done!");

Please make sure that you are using latest version of Aspose.Note for .NET. It looks like you are still using older version in your project.

Strange
image.png (36.1 KB)
Always the same problem, with a new project where I added the nugget package

System.TypeInitializationException
HResult=0x80131534
Message=The type initializer for ‘ ​’ threw an exception.
Source=Aspose.Note
StackTrace:
at ​.()
at Aspose.Note.Page…ctor(Document document)
at .​ ()
at .​ ()
at .()
at .​ ()
at .(Stream , Document , LoadOptions )
at Aspose.Note.Document.(String , LoadOptions )
at Aspose.Note.Document…ctor(String filePath, LoadOptions loadOptions)
at Aspose.Note.Document…ctor(String filePath)
at newTestAsposeOne.Program.Main(String[] args) in D:\test\newTestAsposeOne\newTestAsposeOne\Program.cs:line 14

Inner Exception 1:
InvalidDataException: It seems stream contains non TrueType font.

Inner Exception 2:
InvalidDataException: It seems stream contains non TrueType font.

@PhHElia,
Please share your complete solution containing simple console application for our reference as we are not able to reproduce this issue here.

@PhHElia,
We have observed that issue is not reproduced in Windows 7/10 but it is reproduced in macOS and raises same exception as shared by you. Could you please ensure that all the fonts are installed on the target system that are used in the .ONE file? Also try this piece of code on some other Windows system and share your feedback. We will analyze your feedback and log an investigation ticket if required.

Some information on the environment used:

  • My dev. computer is a Window server 2016 with VS 2017
  • The target computer will be, if I can read the files, an IIS server

I tested the following:
From my pc, I copied the directory windows/fonts to my dev. computer and installed it. Always the same problem.
I can try the application on the IIS server, but not a lot of hope.
I will try to have a “standard” PC to try it. For security reason, I can’t try on my own PC.
I will search on original document the used fonts and verify if they are on my dev. server.

@PhHElia,
Thank you for sharing this information. Please take your time to test it on standard pc and share your feedback.

It’s working on a standard PC.
For me, it’s not a good news as the program must run on a Windows server 2016.
I tested the following on standard PC.
Open document, save it as html, with fonts, css, images, …

var options = new HtmlSaveOptions()
{
ExportCss = ResourceExportType.ExportAsStream,
ExportFonts = ResourceExportType.ExportAsStream,
ExportImages = ResourceExportType.ExportAsStream,
FontFaceTypes = FontFaceType.Ttf
};
document.Save(dataDir + “document_out.html”, options);

The fonts in the subdirectory are all on the server.

Problem found:

Aspose.note V21.5 is not Supported on Windows server 2016
My test is good working on Windows 2012 R2.

Is support planned for Windows server 2016 ?

@PhHElia,
Thank you for providing more information. We have logged an investigation ticket and will write back here once any update is ready for sharing.

This issue is logged as:
NOTENET-3314 - Aspose.Note does not work on Windows server 2016 whereas it works on Windows 2012 R2/Windows 7/Windows 10

@PhHElia,
We have tried to reproduce the issue but haven’t been successful. The issue is not reproduced in Docker neither in real Windows Server 2016. We need more information for our reference:

Could you please provide the following information?

  1. What is the exact version of Windows Server 2016 in use?
  2. What is the exact version of .Net SDK?
  3. What permissions have the user executing the app?
  4. Is it possible to build and run his program with our special debug version of Aspose.Note(we will provide special NuGet package)?