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.

https://we.tl/t-3S3ZClUSPb

@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)?

Hello,
1: Windows Server 2016 standard (Version 10.0.14393 Build 14393)
2: .net Framework 4.8 (4.8.03761)
3: administrator
4: Normally, I can do it.
5: I use Visual Studio 2017 (15.9.36)

@PhHElia,
Thank you for the feedback. We have logged it with the ticket for our later reference.

@PhHElia,
You may please try this debug package in your solution and share the feedback.

Hello,
I have problem when trying to install the package.
[Ici] ‘D:\Temp__MACOSX._Aspose.Note_21.5.1.nupkg’ is not a valid nupkg file. Error: ‘The file is not a valid nupkg. File path: D:\Temp__MACOSX._Aspose.Note_21.5.1.nupkg’.
The file is not a valid nupkg. File path: D:\Temp__MACOSX._Aspose.Note_21.5.1.nupkg
End of Central Directory record could not be found.

When I only place the file aspose without the other directory, I have:

Severity Code Description Project File Line Suppression State
Error Package ‘Aspose.Note 21.5.1’ is not found in the following primary source(s): ‘D:\Temp’. Please verify all your online package sources are available (OR) package id, version are specified correctly.

Hello!

I do the following steps:

  1. Using nuget 5.8.1 from https://www.nuget.org/downloads: “nuget add Aspose.Note_21.5.1.nupkg -Source D:\nuget”
  2. In Visual Studio create NuGet feed for folder “D:\nuget”: Tools - Options - NuGet Package Manager -Package Sources
  3. Install the package

The workaround:

  1. Using NuGet Package Explorer extract libraries from package
  2. Manually add reference to Aspose.Note 21.5.1 for target platform

Visual Studio 2017, with the console

PM> Install-Package Aspose.Note_21.5.1.nupkg -Source D:\Temp

Attempting to gather dependency information for package ‘Aspose.Note_21.5.1.0’ with respect to project ‘newTestAsposeOne’, targeting ‘.NETFramework,Version=v4.8’
Install-Package : Package ‘Aspose.Note_21 5.1’ is not found in the following primary source(s): ‘C:\WINDOWS\system32’. Please verify all your online package sources are available (OR) package id, versi
on are specified correctly.
At line:1 char:1

  • Install-Package Aspose.Note_21.5.1.nupkg -Source D:\Temp
  •   + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
      + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
    
    

Time Elapsed: 00:00:00.3399860
PM>