Aspose.Note kills OneNote files during save

Hi Aspose team,

in attached document you’ll find 4 videos where I am using Aspose.Note following versions:

  • 18.11 (video 1)
  • 18.11 (video 2)
  • 18.9
  • 18.7

Basically I am searching hyperlinks in documents and making replacement. To save new file I am using following code:

              fs = File.Open(path, IO.FileMode.OpenOrCreate)
              fs.SetLength(0)
              doc.Save(fs, SaveFormat.One)

From videos you’ll see that versions 18.11 and 18.9 are randomly kill documents by saving files with 0 bytes size. Version 18.7 works ok.

Unfortunately this time I cannot provide sample project as this is part of bigger project. Also before saving I checked fs.length and it is always correct with number of bytes of existing file.

Btw. I am opening file, make changes in memory and saving back (overwrite) to do original file.

Videos: OneNote.zip (1.2 MB)
Here are sample files from videos but I do not think that they are root-cause as like said save works with 18.7:

OneNoteSampleFiles.zip (3.1 MB)

Considering high number of my OneNote tickets in last weeks I am really concern with Aspose.Note quality for productive usage :frowning:

Thanks for help,
Oliver

@dr_oli

We tried to reproduce this issue using the code sample provided but we are unable to reproduce this issue with Aspose.Note for .NET 18.11. The document is saving successfully. Can you please provide steps to reproduce this issue along with complete code sample in case we may have missed something.

Unfortunately this is part of the huge project which we cannot share.
I am not sure if this helps but in attachment you can see StackTrace.

OneNoteIssue0bytes.pdf (96.7 KB)

Thanks,
Oliver

@dr_oli

Thank you for your feedback. It looks that you are using VB.NET so we will investigate it again and will let you know soon.

@dr_oli

It is requested to kindly share .NET SDK version that is being used as we are still unable to reproduce this issue. It would be great if you could just create simple project for us reproducing this error.

Hi Muzammil,

I’ll try to create more complete project as I was not able to see this issue anywhere but in core application.
Btw. we use .Net 4.5.2.

BR and thanks for tries,
Oliver

Btw. I just noticed that when I try:

doc.Save(fs, SaveFormat.One)

Error message that I am getting is “Object is currently in use elsewhere.”

and stack file is like provided before:
at System.Drawing.Graphics.set_PageUnit(GraphicsUnit value)
at ​ .​ (String , Font )
at .(String , )
at .(Char )
at .(String )
at .(String , Single , TextStyle , IList1 , HorizontalAlignment , Single , ) at Aspose.Note.RichText.(Single ) at Aspose.Note.RichText.6vw7a38rx8hq7gf3sc2fzmpqyry3cca8 (SizeF ) at Aspose.Note.Node.(SizeF ) at Aspose.Note.CompositeNode1.6vw7a38rx8hq7gf3sc2fzmpqyry3cca8 (SizeF )
at Aspose.Note.Node.(SizeF )
at Aspose.Note.CompositeNode1.6vw7a38rx8hq7gf3sc2fzmpqyry3cca8 (SizeF ) at Aspose.Note.Node.(SizeF ) at Aspose.Note.TableRow.6vw7a38rx8hq7gf3sc2fzmpqyry3cca8 (SizeF ) at Aspose.Note.Node.(SizeF ) at Aspose.Note.CompositeNode1.6vw7a38rx8hq7gf3sc2fzmpqyry3cca8 (SizeF )
at Aspose.Note.Node.(SizeF )
at Aspose.Note.CompositeNode1.6vw7a38rx8hq7gf3sc2fzmpqyry3cca8 (SizeF ) at Aspose.Note.Node.(SizeF ) at Aspose.Note.CompositeNode1.6vw7a38rx8hq7gf3sc2fzmpqyry3cca8 (SizeF )
at Aspose.Note.Outline.6vw7a38rx8hq7gf3sc2fzmpqyry3cca8 (SizeF )
at Aspose.Note.Node.(SizeF )
at Aspose.Note.CompositeNode`1.6vw7a38rx8hq7gf3sc2fzmpqyry3cca8 (SizeF )
at Aspose.Note.Page.6vw7a38rx8hq7gf3sc2fzmpqyry3cca8 (SizeF )
at Aspose.Note.Node.(SizeF )
at Aspose.Note.Page.()
at Aspose.Note.Page.get_PageLayoutSize()
at . ()
at ​ . ( )
at . ()
at .(Document )
at .(Document , Stream , OneSaveOptions )
at .(Document , Stream , SaveOptions )
at .(Document , Stream , SaveFormat )
at Aspose.Note.Document.Save(Stream stream, SaveFormat format)
at…

I am running multi document processing where each document is opened in a separate thread but they run in parallel. Now after searching and checking stack file it looks like that you are using System.Drawing.Graphics.set_PageUnit(GraphicsUnit value) and according to different search results this is not thread safe which is killing Aspose components and making them not usable for multithread processing.

If I disable and process document one by one nothing is corrupted.

Just search for ““object is currently used elsewhere” + System.Drawing.Graphics.set_PageUnit”.

As I do not experience this issue with 18.7 (at least I was not able to recreate it) I suppose that you made some changes between that and higher versions. I’ll try now to convert my test project to multithread project.

Please find attached project where you can recreate the problem:

OneNote.Bugs.zip (8.5 MB)

IMPORTANT: I believe that I saw similar also with Powerpoint and/or maybe Visio files. Will try to recreate but would be great if you can check with responsible colleagues if they are doing something similar to what is in OneNote. This is really bad, bad issue as it simply kills documents.

P.S. I tried this project also with Aspose.Note 18.7 and it worked ok.

@dr_oli

Thank you for such a detailed feedback and the project file.

We have tested to find out the error but the provided project is working fine. We add OpenFile(“1.one”) right after th5.Start(“5.one”) and on exception occur on this line:

doc.Save(fs, SaveFormat.One)

However, we found that updateHyperlinks() methos is always getting “doc” with “Nothing” resulting following exceptions

Exception thrown: 'System.IO.IOException' in mscorlib.dll
Exception thrown: 'System.NullReferenceException' in OneNote.Bugs.exe
Exception thrown: 'System.ArgumentException' in mscorlib.dll

Moreover, we are investigating this and will update you soon.

Hi,

this is weird as I just copied same exe to totally different computer and was able to recreate the problem. Please check attached video:

OneNote.zip (79.6 KB)

On this computer I do not have Visual Studio so simple button clieck was enough to kill 3 documents.

BR,
Oliver

Few pages talking about similar problems:

https://social.msdn.microsoft.com/Forums/vstudio/en-US/92e17aaf-b020-47c8-8ee1-9672bbf461ac/quotobject-is-currently-in-use-elsewherequot-error-for-picturebox?forum=csharpgeneral

Here recommendation was:
You should dispose the Graphics object when you’re done drawing and not keep a reference to it in the class. curveGraphics should be a local variable of plotGraph.

It was confirmed that this resolved the problem.

Are you disposing Graphics objects?

And a blog entry with more details:
https://blogs.msmvps.com/peterritchie/2008/01/28/quot-object-is-currently-in-use-elsewhere-quot-error/

@dr_oli

Thank you for your feedback. We have logged this issue with ID “NOTENET-2749” for further investigation. We will update you here once we have more information to share.

Hi Muzammil,

does that mean that you can recreate the issue?
I mean issue where files are saved with 0 bytes size.

Thanks,
Oliver

In case that anybody else wants to check locally if you have the same problem - sample project link:

https://1drv.ms/u/s!AgRYkfuD1R_IxklISO44Abfv6ylL

I used Aspose.Note 19.1 but same problems is also with 18.11 and 18.9.

Would be great if you can let us know about your testing results…

@dr_oli

Thank you for writing back to us. We have reproduced the issue partially, we are not getting “object is currently used elsewhere” but files are saving with 0. So we have logged this issue for investigation.

Moreover, we will share our findings on provided sample project soon.

@dr_oli

We have prepared Aspose.Note for .NET 19.1.1 hot fix release . Please download at from link given below and provide your feedback.

Hi Muzammil,

thanks for hotfix. I just replaced DLL in test project and all works good. I’ll continue with tests in main project but this looks promising. Most likely I can share next feedback tomorrow.

Thanks,
Oliver

Just to confirm that also in main project save works as expected now :smile:

Thx

@dr_oli

Thank you for your feedback.

We are glad to know that the issue is resolved now. Please feel free to write back to us if you have any further queries in this regard.

The issues you have found earlier (filed as NOTENET-2749) have been fixed in Aspose.Note for .NET 19.3. This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi