when I am running application in multithread mode (5 documents loaded in parallel) and I make some changes in OneNote files and try to save them I am getting different errors plus sometimes files are saved with 0 bytes (basically they are killed).
I attached project with 5 OneNote files and when you press button Update most likely each time you will see different errors during save and probably also catch 0 bytes save issue.
In most cases error is “An item with the same key has already been added.”
It is interesting that not always the same file is affected.
@dr_oli,
I have tried this sample project and observed that when I manually open 2.one file in Microsoft OneNote 365, it shows an error as follows:
We couldn't merge some changes. Click here to see page versions with unmerged changes
It shows that this file has issue and should be replaced with a file which can be opened in MS OneNote without any error.
If we comment this file’s (2.one) processing and run the code, no issue is observed and all the files are saved properly. Please ensure that you give appropriate time after pressing the “Update” button to let the threads finish their tasks. Like in the beginning you will see file 3.one and 5.one as 0 bytes, but if you wait for a while for the threads to finish their tasks, you will see that these 0 byte files are populated properly and can be opened in MS OneNote without any error.
You may please try same scenario for file 2.one once it is replaced with an error free file and share the feedback.
Note that I have commented the MsgBox() function and replaced it with Console.WriteLine(). You may write it to some log file as well.
Here the final version of Form1.vb file is attached for your reference which worked fine here. Form1.zip (1.6 KB)
@dr_oli,
Good to know that your issue is sorted out. Feel free to contact us at any time if you need further help or have some other issue or queries, we will be happy to assist you soon.