Programmatically writing text in OneNote 2010 and 2013 RRS feed

  • Question


    I use C# and Visual Studio 2010 to develop programs involving OneNote. I have a PC at work that has 32-bit Windows 7 and Office 2010. I also have a laptop with 64-bit Windows 8 and 32-bit Office 2013. I want to build programs that will run on both computers, but I can't get this to work.

    I am testing this by having a small console program that reads the text of the current paragraph in OneNote and prints this to the console, and it also adds a small paragraph of text to the end of the current OneNote page.

    If I build this program (Target framework 3.5, configuration Debug / x86) on the Windows 7 / Office 2010 computer, using C:\Program Files\Microsoft Visual Studio 10.0\Visual Studio Tools for Office\PIA\Office14\Microsoft.Office.Interop.OneNote.dll, this runs just fine. However, if I try to run this on the laptop with Windows 8 / Office 2013, the reading part is no problem, but the attempt to add text raises an exception: Invalid XML.

    If I now rebuild the program on the laptop, using c :\Windows\assembly\GAC_MSIL\Microsoft.Office.Interop.OneNote\\Microsoft.Office.Interop.OneNote.dll, everything is good on the laptop, but the program will fail on the Windows 7 machine: TypeInitializationException.

    I have lost track of all the different combinations and permutations and OneNote assembly versions I have tried, but I cannot get this resolved. Currently, I build separate executables for each machine, but this feels very awkward.

    Can anyone help me out here? Maybe this has to do simply with the fact that Office 2013 still has "Preview" status? Is there an XML schema conflict? Or am I overlooking something obvious?

    Thursday, November 22, 2012 6:48 AM


  • Hi Jan Roelof de Pijper,

    Thank you for posting in the MSDN Forum.

    Since the PIAs are against different OneNote versions, I suggest you build the application against the 2 versions of OneNote respectively.

    I've found that the OneNote 2013 developer reference on this page is unavailable, I'll inform you if there's any update.

    Hope it helps.

    Best regards,

    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us

    Friday, November 23, 2012 2:14 PM