The specified package is invalid. The main part is missing RRS feed

  • Question

  • hello everybody,

    Iam creating a word add-in for word 2007 with visual c# 2008. i got this error. could anyone help?


    using re = Microsoft.Office.DocumentFormat.OpenXml.Packaging;

    using Word = Microsoft.Office.Interop.Word;

    using Office = Microsoft.Office.Core;



    namespace wordplugin


    public partial class ThisAddIn


    const string wordmlNamespace = "";

    const string relationshipNamespace = "";

    private void ThisAddIn_Startup(object sender, System.EventArgs e)


    XmlDocument xmlProperties = new XmlDocument();

    //string str = "test5.docx";

    using (re.WordprocessingDocument wordDoc = e.WordprocessingDocument.Open(@"c:\check\test5.docx",false))  // in this line.


    re.ExtendedFilePropertiesPart appPart = wordDoc.ExtendedFilePropertiesPart;



    XmlNodeList chars = xmlProperties.GetElementsByTagName("Characters");



    Thank you.



    Wednesday, March 26, 2008 2:43 PM

All replies

  • Try to open your file using package class. Add Reference "WindowsBase" to your project. and then use System.IO.Packaging.Package.

    that will be easier.

    check the following link:
    • Proposed as answer by sibasissinha Saturday, August 10, 2019 11:56 AM
    Monday, September 22, 2008 12:09 PM
  • I"m afraid it is because the package you're trying to open is invalid. Please make sure the package has the part of "maindocument.xml".


    This error may occur at this situation: the package tried to open is created by the windows context menu, then its size is 0 until you open the file and save it even without any changes in Word 2007. After open-and-save, the file should be opened correctly by the SDK.


    • Proposed as answer by mrdivo Tuesday, November 25, 2008 6:40 PM
    Wednesday, September 24, 2008 3:44 AM