none
WordprocessingDocument.Open error on Windows 10 Version 1703, but works in Windows 10 Version 1607 RRS feed

  • Question

  • Receiving an error message on this line of code:

    (WordprocessingDocument myDoc = WordprocessingDocument.Open(newFilePath, true))

    It works on Version 1607, but errors on 1703. 

    I'm wondering why that update would cause an error in the code.

    Here is the code leading up to that line:     

    XPathNavigator root = MainDataSource.CreateNavigator();  string InvoiceNumber = "";          

    XPathNodeIterator Initial = root.Select("//my:myFields", NamespaceManager);           

    while (Initial.MoveNext())               

    {                    InvoiceNumber = Initial.Current.SelectSingleNode("my:Invoice_Number", NamespaceManager).Value;

                        InvoiceNumber = InvoiceNumber.Replace(":", "");                                  

    }                using (new Tools.Impersonator("username", "domain", "password"))               

    {                       string newFilePath = @"\\sharepoint\AP\ExpenseWord\" + InvoiceNumber + ".docx";                                           

    string TemplatePath = @\\sharepoint\AP\ExpenseWord\Template1.docx;                                    

    File.Copy(TemplatePath, newFilePath, true);                                 

    using (WordprocessingDocument myDoc = WordprocessingDocument.Open(newFilePath, true))                                        {


    Monday, October 9, 2017 8:17 PM

All replies

  • Below is the error message:

    The type initializer for 'MS.Utility.EventTrace' threw an exception.
       at MS.Utility.EventTrace.EasyTraceEvent(Keyword keywords, Event eventID)
       at System.IO.Packaging.Package.Open(String path, FileMode packageMode, FileAccess packageAccess, FileShare packageShare, Boolean streaming)
       at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.OpenCore(String path, Boolean readWriteMode)
       at DocumentFormat.OpenXml.Packaging.WordprocessingDocument.Open(String path, Boolean isEditable, OpenSettings openSettings)
       at DocumentFormat.OpenXml.Packaging.WordprocessingDocument.Open(String path, Boolean isEditable)
       at Expense.FormCode.btnApprovedIcon_Clicked(Object sender, ClickedEventArgs e)
       at Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)
       at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)

    Monday, October 9, 2017 8:21 PM