locked
Microsoft.Office.Interop.Word.Documents.Open Issue : ASP.NET application hosted in Windows 2008 Server RRS feed

  • Question

  • Hi,
    I am creating an MS Office Word 2007 Automation application in ASP.NET. Here I will read a predefined .dot(template file) and fill the contents with some dynamics data and save it. I am reading the file from"c:\Documents\Templates\XXX.dot".
    1. When I am executing from my VS development application(localhost:portnumber) it is working perfectly.
    2. When I am hosting in my same system(Windows XP Professional) by creating virtual directory in inetmgr and executing also working perfectly.
    3. My problem occurs where:
    When i am hosting the same application in my production server(Windows Server 2008) I am getting error as

    Data: System.Collections.ListDictionaryInternal
    Message: Word has encountered a problem.
    Source: Microsoft Word


    The code fails at the below specified line in wordApp.Documents.Add
    ApplicationClass wordApp = new Microsoft.Office.Interop.Word.ApplicationClass();

    Document wordDoc = wordApp.Documents.Add(ref oTemplate, ref oFalse, ref oMissing, ref oMissing);

    // The code fails at this line.
    The above code is called as per the following flow .ASPX Page --> Silverlight(.XAP) file(button click) --> .SVC Web Service --> actual code that raises error written in library(dll) here is where the error is.
    I cannot proceed further and i am stuck with his. If anybody came up with this error please help me in solving this issue. I was nearly 2 weeks stuck with this app.

    Thank you.
    Ashok

    Thursday, August 19, 2010 6:28 AM

Answers

  • Hi Ashok,

    The application architecture you are employing is not recommended and supported by Microsoft. MS Office has never been designed or tested for this kind of usage.

    Please refer to the following knowledge Base article:

    257757 INFO: Considerations for Server-Side Automation of Office
    http://support.microsoft.com/?id=257757

    You are attempting to utilize automation of Microsoft Office in an unattended, non-interactive solution. There are many known complications associated that I want you to be fully aware of before you continue your development project. Microsoft Office was not designed to accommodate server side automation and, therefore, it is untested and unsupported. In addition, Office cannot be changed to run effectively as a server-side component and stay compatible to its design as an end-user application. We cannot offer software updates, patches or production code to support or provide a solution for your issue.

    You may seek to mitigate the effects of certain problems through your own code or server configuration, but you will need to fully test and deploy it at your own risk as you would any custom solution. We highly suggest you review the design of your project and implement one of the known alternatives.

    Should you choose to continue with a server side solution, we want you to be aware of the known problems including but not limited to:

    •Security issues
    •Reentrancy and scalability
    •Stability
    •Upgrade issues
    •Licensing implications
    As a workaround, I recommend using Office Open XML formats to generate Office documents. The Open XML file formats are a public standard.

    Microsoft provides an SDK for manipulating Open XML file formats from the .NET 3.x Framework. For more information about the SDK and about how to use the SDK to create or edit Open XML files, visit the following Microsoft Developer Network (MSDN) Web sites:

    Open XML SDK Documentation
    http://msdn.microsoft.com/en-us/library/bb226703.aspx
    How to: Manipulate Office Open XML Formats Documents
    http://msdn.microsoft.com/en-us/library/aa982683.aspx
    Manipulating Word 2007 Files with the Open XML Object Model (Part 1 of 3)
    http://msdn.microsoft.com/en-us/library/bb656295.aspx
    Manipulating Word 2007 Files with the Open XML Object Model (Part 2 of 3)
    http://msdn.microsoft.com/en-us/library/bb739835.aspx
    Manipulating Word 2007 Files with the Open XML Object Model (Part 3 of 3)
    http://msdn.microsoft.com/en-us/library/bb727374.aspx
    Manipulating Excel 2007 and PowerPoint 2007 Files with the Open XML Object Model (Part 1 of 2)
    http://msdn.microsoft.com/en-us/library/bb739834.aspx
    Manipulating Excel 2007 and PowerPoint 2007 Files with the Open XML Object Model (Part 2 of 2)
    http://msdn.microsoft.com/en-us/library/bb727373.aspx
    Building Server-Side Document Generation Solutions Using the Open XML Object Model (Part 1 of 2)
    http://msdn2.microsoft.com/en-us/library/bb735940.aspx
    Building Server-Side Document Generation Solutions Using the Open XML Object Model (Part 2 of 2)
    http://msdn2.microsoft.com/en-us/library/bb735939.aspx


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Friday, August 20, 2010 11:39 PM

All replies

  • Hi, did you find a resolution to this, I'm having the same problem
    Thursday, August 19, 2010 5:36 PM
  • Hi Ashok,

    The application architecture you are employing is not recommended and supported by Microsoft. MS Office has never been designed or tested for this kind of usage.

    Please refer to the following knowledge Base article:

    257757 INFO: Considerations for Server-Side Automation of Office
    http://support.microsoft.com/?id=257757

    You are attempting to utilize automation of Microsoft Office in an unattended, non-interactive solution. There are many known complications associated that I want you to be fully aware of before you continue your development project. Microsoft Office was not designed to accommodate server side automation and, therefore, it is untested and unsupported. In addition, Office cannot be changed to run effectively as a server-side component and stay compatible to its design as an end-user application. We cannot offer software updates, patches or production code to support or provide a solution for your issue.

    You may seek to mitigate the effects of certain problems through your own code or server configuration, but you will need to fully test and deploy it at your own risk as you would any custom solution. We highly suggest you review the design of your project and implement one of the known alternatives.

    Should you choose to continue with a server side solution, we want you to be aware of the known problems including but not limited to:

    •Security issues
    •Reentrancy and scalability
    •Stability
    •Upgrade issues
    •Licensing implications
    As a workaround, I recommend using Office Open XML formats to generate Office documents. The Open XML file formats are a public standard.

    Microsoft provides an SDK for manipulating Open XML file formats from the .NET 3.x Framework. For more information about the SDK and about how to use the SDK to create or edit Open XML files, visit the following Microsoft Developer Network (MSDN) Web sites:

    Open XML SDK Documentation
    http://msdn.microsoft.com/en-us/library/bb226703.aspx
    How to: Manipulate Office Open XML Formats Documents
    http://msdn.microsoft.com/en-us/library/aa982683.aspx
    Manipulating Word 2007 Files with the Open XML Object Model (Part 1 of 3)
    http://msdn.microsoft.com/en-us/library/bb656295.aspx
    Manipulating Word 2007 Files with the Open XML Object Model (Part 2 of 3)
    http://msdn.microsoft.com/en-us/library/bb739835.aspx
    Manipulating Word 2007 Files with the Open XML Object Model (Part 3 of 3)
    http://msdn.microsoft.com/en-us/library/bb727374.aspx
    Manipulating Excel 2007 and PowerPoint 2007 Files with the Open XML Object Model (Part 1 of 2)
    http://msdn.microsoft.com/en-us/library/bb739834.aspx
    Manipulating Excel 2007 and PowerPoint 2007 Files with the Open XML Object Model (Part 2 of 2)
    http://msdn.microsoft.com/en-us/library/bb727373.aspx
    Building Server-Side Document Generation Solutions Using the Open XML Object Model (Part 1 of 2)
    http://msdn2.microsoft.com/en-us/library/bb735940.aspx
    Building Server-Side Document Generation Solutions Using the Open XML Object Model (Part 2 of 2)
    http://msdn2.microsoft.com/en-us/library/bb735939.aspx


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Friday, August 20, 2010 11:39 PM
  • Hi all,

    I am also having problem with Microsoft.Office.Interop.Word.ApplicationClass.

    My application is build upon .Net framework 2.0. OS : Windows server 2008 R2. IIS : 7.5

    Error is at line Microsoft.Office.Interop.Word.ApplicationClass obj = new Microsoft.Office.Interop.Word.ApplicationClass();

    Object reference not set to the instance of object and stacktrace is showing message Microsoft.Office.Interop.Word.ApplicationClass.get_ActiveDocument() only.

    Regards,

    Anil N.

    Friday, June 17, 2011 12:43 PM
  • Hi

    I am facing similar issue with same environment

    Please reply me if you have got the solutions

     

    regards

    Wednesday, September 7, 2011 10:19 AM
  • Hi

    I am also same problem .if u know, please help me.

    Thanks in advance

    vinoth

    Monday, February 27, 2012 1:52 PM