TechNote - Interop

Sunday, March 12, 2023

9:38 PM

The OneNote primary Interop assembly exposes a set of interfaces available to add-ins like OneMore. Like most other Office applications, OneNote has its own implementation of IApplication which declares properties and methods for interrogating the state of OneNote and requesting and updating page and hierarchy information.

 

The typical path of the OneNote PIA is C:\Program Files (x86)\Microsoft Visual Studio\Shared\Visual Studio Tools for Office\PIA\Office15\Microsoft.Office.Interop.OneNote.dll

 

OneMore encapsulates all access to the OneNote IApplication and Window interfaces through the River.OneMoreAddIn.OneNote class.

 

Interop Signaling Flow

While I do not have access to internal Microsoft design documents, we can infer the basic signaling between OneNote and an add-in. That likely resembles something like the following.

 

OneMore Interop Signaling Flow

 

In general, when OneMore receives a signal from OneNote to execute a command, it then executes a workflow to interact with Onenote, including getting page or hierarchy information, processing that information, and sending an updated copy back to OneNote.

 

The OneNote IApplication interface exposes all OneNote information as XML. From OneMore's perspective, this is the native language it uses to talk to OneNote.

 

While requesting information from OneNote seems to be very quick, pushing updated information back to OneNote via its Interop layer can be very slow, which is evident when updating large or complex pages, especially those containing tables. OneMore logs execution times and even time-to-save for some particularlly troublesome commands, like Recalculate Formula.

 

 

──────────────────────────────────────────────────────────────────────────────────────────────────

OneMore Interop Signaling Flow PlantUML (Refresh)

@startuml

title OneMore Interop Signaling Flow

skin rose

skinparam ParticipantPadding 20

skinparam BoxPadding 80

scale max 450 width

autonumber

database one as store #LavenderBlush

participant OneNote

box dllhost

participant Interop #AliceBlue

participant OneMore

end box

note over OneNote: User initiates command from\nribbon, palette, or shortcut

OneNote -> Interop: Command

activate Interop #AliceBlue

Interop -> OneMore: Execute()

activate OneMore

OneMore -> Interop: GetPageContent

deactivate OneMore

Interop -> OneNote

OneNote --> store

store --> OneNote: Native models

note right: transform native models to XML

OneNote --> OneNote: Transform

OneNote --> Interop: XML

Interop --> OneMore: XML

activate OneMore

OneMore -> OneMore: process

OneMore -> Interop: UpdatePageContent()

Interop -> OneNote

OneNote --> OneNote: Transform

note right: transform XML to native models

OneNote --> store: Native models

deactivate OneMore

deactivate Interop

@enduml

 

#omwiki #omdeveloper #omtechnote

 

© 2020 Steven M Cohn. All rights reserved.

Please consider a sponsorship or one-time donation to support ongoing development

 

 

 

Created with OneNote.