Cannot use OneNote interop in v6 - missing COMImportAttribute
LINQPad 6 now has the ability to reference Office COM primary interop assemblies through, apparently, a specialized nuget. However, this does not include the OneNote PIA.
Add the OneNote PIA manually via C:\Program Files (x86)\Microsoft Visual Studio\Shared\Visual Studio Tools for Office\PIA\Office15\Microsoft.Office.Interop.OneNote.dll
Also add a reference to Office.dll
Then create an instance of Application with var onenote = new Application();
LINQPad complains with
CS1756 Interop type 'IApplication' cannot be embedded because it is missing the required 'System.Runtime.InteropServices.ComImportAttribute' attribute.
This worked in LINQPad 5 (probably because it was based on .NET Framework instead of .NET Core). Is there a way to reference this assembly in LINQPad 6?
Comments
Note that I can reference a .NET Framework assembly that wraps the OneNote PIA APIs and call that from a LINQPad 6 query so this is at least a workaround.
Have you tried referencing the Interop.Microsoft.Office.Interop.OneNote NuGet package?