OneNote 2010 and Visual Studio 2010 – compatibility issues

I wanted to highlight some issues developers might have if they try and program against the OneNote 2010 API with Visual Studio 2010.

Make sure to reference the COM API and not the .Net API

First of all there is an issue with the interop assembly that shipped with Visual Studio 2010, it is out of date because we had to make a change to the API after the VS team took their final drop.  It is sad that this happened and working across teams but it just means that you should NOT reference the OneNote 14.0 object from the .Net tab and instead reference it from the COM tab:



Make sure to turn off ‘Embed Interop Types’

There is a new feature in Visual Studio 2010 where most PIAs are no longer embedded in the application by default, this has been called the NOPIA.  Misha Shneerson has some details about this on his blog here:  Better eventing support in CLR 4.0 using NOPIA support.

However OneNote 2010’s typelib is not compatible with this feature and by default after you have added a reference to OneNote 2010 typelib you will see this error:

Error    1    'Microsoft.Office.Interop.OneNote.Application' does not contain a definition for 'GetHierarchy' and no extension method 'GetHierarchy' accepting a first argument of type 'Microsoft.Office.Interop.OneNote.Application' could be found (are you missing a using directive or an assembly reference?)    C:\ConsoleApplication1\ConsoleApplication1\Program.cs    15    19    ConsoleApplication1

This was from the 'GetHierarchy' method but you would see it with any method you call into OneNote.  This is due to the new NOPIA option and you would need to turn if off to get things working again.

Turning off NOPIA/embed interop types for OneNote 2010:

  1. Find the reference to Microsoft.Office.Interop.OneNote on the Solution Explorer
  2. Click on it and view the properties down below
  3. Find the value Embed Intero Types and change it from True to False
  4. Recompile and you should be all set


Now you should be all set.

I will blog more about other OneNote 2010 API/extensibility changes but in the meantime I wanted to pass on some of these details to make sure you weren’t blocked.  Visual Studio 2008 & 2005 shouldn’t have this problem because it was a new feature in VS2010 and .Net 4.

Comments (7)

  1. Milesa84 says:

    A concise guide to the steps in litter training ferrets.

  2. Parrotlover77 says:

    It’s great that a workaround is possible and not too difficult, but would it kill the Visual Studio team to release a hotfix ASAP?  There are going to be a lot of people confused by this who don’t read the ON blogs.

  3. onenotedev says:

    Good to know!

    I wonder if there's any Onenote 2010 API reference out there?

    There's one for Onenote 2007 (…/ms788684%28office.12%29.aspx) but there's none for 2010 yet


  4. Phil says:

    Is there anyway to create a ribbon tab for OneNote. I followed the steps you provided and the steps here…/vsto-add-ins-for-access.aspx, but my DLL wasn't loaded.


  5. Olya Veselova says:

    It looks like this may be an issue specifically with .Net 4.0.

    I first compiled in Visual Studio C# Express 2010 and go the error "Microsoft.OneNote.Interop.OneNote.Application does not contain a definition for…". Changing target to .NET Framework 3.5 alowed me to compile – even in Visual Studio 2010 – because .NET 3.5 it does not have the Embed Interop Types property at all.

    But Dan's suggestion works better – I can still use .NET 4.0 and get things to work. Yay!

  6. Rainer says:

    Thank you very much, that solved my problem. Love your blog, there is nothing like it for us few OneNote hackers. 🙂

  7. Steele Price [MVP] says:

    Was this ever corrected?  Will it ever be?

    I'd hate to have to wait for OneNote 15 to make Add-ins targetting Slates.


Skip to main content