none
WordProcessingDocument.Open a very long time to open

    질문

  • Hello! I'm using the OpenXML SDK to handle docx documents.
    Because of what may be a long time to open the document using the methodWordProcessingDocument.Open ("path_to_docx_file", true)? On some computers, open the document takes about 15 seconds, at some instant ... What factors influence the opening of the document? Powerful computer, Intel Core i5, 16GB RAM ...
    File size 10kb
    Sorry for my English.
    Thanks in advance for your help!
    2012년 3월 5일 월요일 오후 4:24

답변

  • Hello!
    We were able to pinpoint the cause of the slow work of the program, as it turned out it was not in the method of opening the document, and in the assemblyDocumentFormat.OpenXml.dll.
    If you have a reference to this assembly, the program is loaded for a long time, then the document opens and closes instantly. The delay comes at the moment of first contact to the assembly DocumentFormat.OpenXml.dll.
    Build DocumentFormat.OpenXml.dll registered in GAC
    2012년 3월 14일 수요일 오전 10:18

모든 응답

  • Hi Gennady Bayanov,
    Thank you for posting. 
    I will help you involve others to help you. There might be some delay about the response. Appreciate your patience.
    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us

    2012년 3월 8일 목요일 오전 9:56
  • Hi Gennady,

    Please correct me if I misunderstand your issue. On some
    systems the document takes as long as 15 seconds to open. On other identical
    systems the document opens instantly.

    The answer to your question “What factors influence the
    opening of the document?” is that there are many possible factors that suggest
    the following questions.

    Do all systems have the same version and service pack level
    of the operating system, and the same service pack level of Microsoft Office?

    Is the path to the document to a location on the computer or
    to a network server or SharePoint location?

    Do all of the systems have the same version and level of the
    XML parser (C:\Windows\System32\MSXML6.dll)? (See the following content:

    Upgrading to MSXML 6.0 - Microsoft XML Team's WebLog - Site Home ...
    http://blogs.msdn.com/b/xmlteam/archive/2007/03/12/upgrading-to-msxml-6-0.aspx
    )

    Is the delay seen the first time the .docx file has been
    opened since the computer was last re-booted, or does it always happen on those
    computers exhibiting the problem?

    If you open the document through the user interface is there
    a delay?

    Does the system have Word Add-ins? If so, does preventing
    those from loading change the performance?

    Please let us know if you have any questions about items in
    the list above.

    Please consider the above list of things that may influence the opening of the
    document and post a reply that tells us whether changing any of those helped
    resolve the behavior.
    Regards,
    Chris Jensen
    Senior Technical Support Lead







    Chris Jensen

    2012년 3월 8일 목요일 오후 7:17
  • Hi Bruce Song and cjatms!

    Thank you for your answers.

    The configuration of the computer on which the document is opened for a long time:
    OS: Microsoft Windows 7 Professional Version 6.1.7601 Service Pack 1 Build 7601System Type: x64-based PC
    Processor: Intel (R) Core (TM) i5-2500K CPU@3.30GHz, 3301 Mhz, 4 Core (s), 4Logical Processor (s)
    Installed Physical Memory (RAM): 16,0 GB
    Total Physical Memory: 15,9 GB
    Available Physical Memory: 13,6 GB
    Total Virtual Memory: 31,8 GB
    Available Virtual Memory: 29,3 GB
    Page File Space: 15,9 GB

    MSXML Version: 6.30.7601.17514 C: \ windows \ system32 \ msxml6.dll

    Microsoft Office is not installed.

    The delay is always, every time you start the application.
    An example of a console application that runs more than 10 seconds:

    class Program
    {
        static void Main (string [] args)
        { 
            try  
            {
                var document = WordprocessingDocument.Open ("testin1.docx", true);    
                document.Close();          
            }     
            catch (Exception exception)   
            {   
                Console.WriteLine (exception.Message);   
            }   
        }  
    }


    2012년 3월 11일 일요일 오전 9:41
  • Hi Gennady,

    When I built and ran your console app on a Windows 7 system the .docx file opened and closed in less than 1 second.  Here is the totality of my Visual Studio 2010 project (after adding appropriae references):

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using DocumentFormat.OpenXml.Packaging;
    
    namespace WordXMLConsoleApplication6
    {
        class Program
        {
            static void Main(string[] args)
            {
                try
                {
                    var document = WordprocessingDocument.Open("testin1.docx", true);
                    document.Close();
    
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception.Message);
                }
                        
    
            }
        }
    }
    

    You show nothing in your system description that suggests an explanation for your issue, but something that you haven't identified is responsible. If you have another system that doesn't demnstrate the delay (you said that at "at some instant " about the delay) please look closely at the security settings, location of the .docx file, location of the Open XML SDK, network traffic, and other aspects of the environments of the two systems - the slow one v. a fast one.

    Regards,
    Chris Jensen
    Senior Technical Support Lead


    Chris Jensen

    2012년 3월 12일 월요일 오후 4:04
  • Hello!
    We were able to pinpoint the cause of the slow work of the program, as it turned out it was not in the method of opening the document, and in the assemblyDocumentFormat.OpenXml.dll.
    If you have a reference to this assembly, the program is loaded for a long time, then the document opens and closes instantly. The delay comes at the moment of first contact to the assembly DocumentFormat.OpenXml.dll.
    Build DocumentFormat.OpenXml.dll registered in GAC
    2012년 3월 14일 수요일 오전 10:18
  • Hello!

    The problem solved by setting the properties TragetFramework 4.0

    Thank you all for your help!

    2012년 3월 17일 토요일 오후 2:35