alxnbl/onenote-md-exporter

Corrupted Page cause the app to crash during export

garyo opened this issue · 12 comments

garyo commented

Describe the bug
Got a crash while exporting the first page of the first notebook:

-----------------------
- OneNote Md Exporter -
       v1.1.0.0
-----------------------

Before continue, please verify that :

* OneNote and Word of Office suite are correctly installed
* OneNote is running and the Notebooks to export are opened
* PanDoc software is installed (https://pandoc.org/installing.html)
This tool and OneNote are started with normal priviledges (NOT as an administrator)

Known limitations:
* The free application 'One Note For Windows' is not supported
* File attachments with certain extensions are not exported, including : wma, wmv, mpg, svg, mp3 (Issue #39)
* Password protected sections are not exported
* Hand-writting text is not exported

/!\ Allways keep a backup of your OneNote notebooks in case you discover later that some data is missing in the export /!\

Press [Enter] to continue...


***************************************
2 notebook(s) found(s).
***************************************

Please enter the notebook number to export, or a coma separated list of value (ex: "2,3,4") :
[0] Export all notebooks
[1] Gary's Notebook
[2] DSS
0

Please choose export format:
[1] Markdown
[2] Joplin Raw Folder
1

Open advance settings editor ?
[yes] or [Enter] to continue with current settings
yes

***************************************
Start exporting notebook: Gary's Notebook
***************************************
--> Found 23 sections

Start processing section (1/23) :  Gary's Notebook\Quick Notes\Quick Notes
Unhandled exception. System.Runtime.InteropServices.COMException (0x800706BE): The remote procedure call failed. (0x800706BE)
   at Microsoft.Office.Interop.OneNote.IApplication.GetPageContent(String bstrPageID, String& pbstrPageXmlOut, PageInfo pageInfoToExport, XMLSchema xsSchema)
   at alxnbl.OneNoteMdExporter.Helpers.OneNoteExtensions.FillSectionPages(Application oneNoteApp, Section section)
   at alxnbl.OneNoteMdExporter.Services.Export.MdExportService.ExportNotebookInTargetFormat(Notebook notebook, String sectionNameFilter, String pageNameFilter)
   at alxnbl.OneNoteMdExporter.Services.Export.ExportServiceBase.ExportNotebook(Notebook notebook, String sectionNameFilter, String pageNameFilter)
   at alxnbl.OneNoteMdExporter.Program.RunOptions(Options opts)
   at alxnbl.OneNoteMdExporter.Program.<>c.<Main>b__1_0(Options options)
   at CommandLine.ParserResultExtensions.WithParsed[T](ParserResult`1 result, Action`1 action)
   at alxnbl.OneNoteMdExporter.Program.Main(String[] args)

[process exited with code 3762504530 (0xe0434352)]

To Reproduce

  • Install exporter
  • Start OneNote (not OFW, just regular OneNote)
  • Start exporter, go through export process
  • See crash occur

Steps to reproduce the behavior.
Ideally, export a basic OneNote notebook (.onepkg) that can be use to reproduce the issue. Tutorial to export .onepkg file is available here.

  • I will try to do this and attach to this issue

Expected behavior
Export without error

Logs
logs.txt

Desktop (please complete the following information):

  • Windows version : 11.0.22000 Build 22000, 64 bits
  • Office Version : Office 365, Version 2111 (build 14701.20262), 64 bit

Additional context
Add any other context about the problem here.

Ahks commented

Heyo, I encountered this error as well.

Troubleshooting seems to point at OneNote crashing while the app is processing specific damaged notes then generating this error since OneNote is no longer running.

Steps I took:

  1. encountered error as @garyo did
PS C:\Program Files\OneNoteMDExporter> .\OneNoteMdExporter.exe
-----------------------
- OneNote Md Exporter -
       v1.1.0.0
-----------------------

Before continue, please verify that :

* OneNote and Word of Office suite are correctly installed
* OneNote is running and the Notebooks to export are opened
* PanDoc software is installed (https://pandoc.org/installing.html)
This tool and OneNote are started with normal priviledges (NOT as an administrator)

Known limitations:
* The free application 'One Note For Windows' is not supported
* File attachments with certain extensions are not exported, including : wma, wmv, mpg, svg, mp3 (Issue #39)
* Password protected sections are not exported
* Hand-writting text is not exported

/!\ Allways keep a backup of your OneNote notebooks in case you discover later that some data is missing in the export /!\

Press [Enter] to continue...


***************************************
8 notebook(s) found(s).
***************************************

Please enter the notebook number to export, or a coma separated list of value (ex: "2,3,4") :
[0] Export all notebooks
[1] My Notebook
[2] MP_Priv
[3] MP_OneNote-2022.01.05
[4] MP_OneNote
[5] MP_Home
[6] MP_**
[7] MP_OneNote
[8] exportMe
8

Please choose export format:
[1] Markdown
[2] Joplin Raw Folder
1

Open advance settings editor ?
[yes] or [Enter] to continue with current settings


***************************************
Start exporting notebook: exportMe
***************************************
--> Found 103 sections

<trimmed>

Start processing section (45/103) :  exportMe\More\**i\**i
   Page 1/13 : Needs
   Page 2/13 : Projects
   Page 3/13 : -- **
   Page 4/13 : -- **
   Page 5/13 : ** Swap
Page 'exportMe\More\**i\** Swap': Error during processing of page ** Swap [f1b006c542af4ccfa511d6ab9bcb51d1]. Page ignored. Error message : The remote procedure call failed. (0x800706BE)
   Page 6/13 : -- Shopping List
Page 'exportMe\More\**i\Shopping List': Error during processing of page -- Shopping List [985c9e82c55d4e328823c3e1cef23807]. Page ignored. Error message : The RPC server is unavailable. (0x800706BA)
   Page 7/13 : ---- **Kits
Page 'exportMe\More\**i\**Kits': Error during processing of page ---- **Kits [eecbc82eda0d45c7bcde370e4784f91f]. Page ignored. Error message : The RPC server is unavailable. (0x800706BA)
   Page 8/13 : -- W**6
Page 'exportMe\More\****i\W**6': Error during processing of page -- W**6 [39657b3c7aeb44d5b425f5f4cfa39956]. Page ignored. Error message : The RPC server is unavailable. (0x800706BA)
   Page 9/13 : -- **-ish sources
Page 'exportMe\More\**i\**-ish sources': Error during processing of page -- **-ish sources [3a30f92087194ad1ab64650d680d7940]. Page ignored. Error message : The RPC server is unavailable. (0x800706BA)
   Page 10/13 : m**r
Page 'exportMe\More\**i\m**r': Error during processing of page m**r [a2bc606d5ca94bae834e36774d8f070c]. Page ignored. Error message : The RPC server is unavailable. (0x800706BA)
   Page 11/13 : Info
Page 'exportMe\More\**i\Info': Error during processing of page Info [3638f6c230b449e2a1304c9cc41890c2]. Page ignored. Error message : The RPC server is unavailable. (0x800706BA)
   Page 12/13 : Maintenance
Page 'exportMe\More\**i\Maintenance': Error during processing of page Maintenance [05a8099d38c04ff28615bf66c6da811b]. Page ignored. Error message : The RPC server is unavailable. (0x800706BA)
   Page 13/13 : L**e
Page 'exportMe\More\**i\L**e': Error during processing of page L**e [5cfc5bb4f2ec4ec29e12d42d46f84153]. Page ignored. Error message : The RPC server is unavailable. (0x800706BA)
Start processing section (46/103) :  exportMe\More\P**n\P**n
Unhandled exception. System.Runtime.InteropServices.COMException (0x800706BA): The RPC server is unavailable. (0x800706BA)
   at Microsoft.Office.Interop.OneNote.IApplication.GetHierarchy(String bstrStartNodeID, HierarchyScope hsScope, String& pbstrHierarchyXmlOut, XMLSchema xsSchema)
   at alxnbl.OneNoteMdExporter.Helpers.OneNoteExtensions.FillSectionPages(Application oneNoteApp, Section section)
   at alxnbl.OneNoteMdExporter.Services.Export.MdExportService.ExportNotebookInTargetFormat(Notebook notebook, String sectionNameFilter, String pageNameFilter)
   at alxnbl.OneNoteMdExporter.Services.Export.ExportServiceBase.ExportNotebook(Notebook notebook, String sectionNameFilter, String pageNameFilter)
   at alxnbl.OneNoteMdExporter.Program.RunOptions(Options opts)
   at alxnbl.OneNoteMdExporter.Program.<>c.<Main>b__1_0(Options options)
   at CommandLine.ParserResultExtensions.WithParsed[T](ParserResult`1 result, Action`1 action)
   at alxnbl.OneNoteMdExporter.Program.Main(String[] args)
PS C:\Program Files\OneNoteMDExporter>
  1. copied my OneNote notebook and opened it as a second notebook in OneNote
  2. ran OneNoteMdExporter.exe again but selecting the copy of my notebook
  3. observed error on the same note
  4. next I exported the notebook to a .onepkg and encountered an error (indicating some data corruption) during export "OneNote cannot pack these sections because some sections have not yet been fully synced and could not be downloaded. These pages will not be saved. Continue anyway?" and selected Yes
  5. opened the .onepkg file this created
  6. ran OneNoteMDExporter.exe again, selecting this 3rd copy
  7. observed the same error on the same note
  8. deleted the note that starts the errors (Page 'exportMe\More*i* Swap') and emptied that notes recycling bin
  9. reran OneNoteMdExporter.exe and it processes properly until it hit my next corrupt note...

As an aside, this tool seems to be a handy way of identifying corrupt notes.

Thank you for your reports. This kind of crash has already been reported by the past but I never bee' able to reproduce it.

Ideally, I need an export of the notebook or the sections causing the crash to reproduce it. Could you join it to the ticket, if the content do not contains any personal data.

There is a brief tutorial here of the export procedure : https://github.com/alxnbl/onenote-md-exporter/blob/main/doc/notebook-onepkg-export.md .

Ahks commented

I managed to create a new notebook with one of my corrupt notes and exported it for you. I also verified that opening this export does create a notebook with my corrupt note and that your app crashes OneNote when processing it.

CorruptNotebook.zip

I am also adding the log from the export attempt
logs.txt

Cheers

Thanks a lot, I will have a look once I have some free time.

garyo commented

And here is my "corrupted" notebook -- all 4 notes in this notebook fail to import even though they open fine in OneNote. I notice that they all have images.

OneNote-temp.onepkg.zip

Great, thank you.

@alxnbl any update on this? I'd love to switch to Joplin but I'm incurring in this bug, even getting the message at point 5 of @Ahks post above when exporting to .onepkg

Hi, if the procedure of @Ahks does not work for you, an alternative solution can be to identify in the export logs which page is beeing proceded during OneNote crash and then manually delete it from OneNote and try exporting again the Notebook. And renew the operation until the export end successfully.

I have 9 notebooks and it seems like a lot of manual work.

I'm not familiar with the source code, but couldn't the tool just catch the exception and do this procedure programatically, maybe warning the user of the pages that were not exported?

Could be a solution, provided that the error returned by OneNote is relevant. But I will probably not have time to work on the tool before a while so do not expect this to be fix soon, sorry. External contributions are welcome ;).

Thank you all for your feedbacks, and @Ahks to share an instance of a corrupted Notebook. It allows me to reproduce the problem and investigate until finding a solution to avoid the app to crash and instead continue the export. Solved in version 1.3.0.

garyo commented

I can confirm this works perfectly now. Thank you!