Problems in Deploy NETOffice on Win2008R2 IIS7

Oct 11, 2012 at 7:12 AM
Edited Oct 11, 2012 at 7:16 AM

I created a project that open / process word document on windows 2003 using VS2008. And it works perfect on windows 2003.

But when I deploy the site to windows 2008, there is an error of null pointer after opening a word document.

The code snippet is doing things that: open a word, and save as htm.

I debug and find variable "oneDocument" is always null, but this code snippet works perfect on windows2003.

(This is not the privilege issue, I already set impersonate as administrator account)

Please help me.... I really don't know what kind of new things in IIS7.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using NetOffice.WordApi.Enums;
using Word = NetOffice.WordApi;

namespace OfficeWebTest
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            SaveWordAsHtm();
        }

        public static void SaveWordAsHtm()
        {
            string wordFile = @"E:\Develop\SQOA\SQOA\InternalProcessing\2012-10-11\2012CS0023\Sharepoint 2010.docx";
            string htmFile = @"E:\Develop\SQOA\SQOA\InternalProcessing\2012-10-11\2012CS0023\Sharepoint 2010.htm";
            WdSaveFormat htmFormat = WdSaveFormat.wdFormatFilteredHTML;

            // start word and turn off msg boxes
            Word.Application wordApplication = new Word.Application();
            wordApplication.DisplayAlerts = WdAlertLevel.wdAlertsNone;

            //open a document
            Word.Document oneDocument = wordApplication.Documents.Open(wordFile);

            // save as filtered htm
            oneDocument.SaveAs(htmFile, htmFormat);

            // close word and dispose reference
            wordApplication.Quit();
            wordApplication.Dispose();
        }
    }
}

Oct 11, 2012 at 7:20 AM

I also tested in VS2010, the code snippet works if I'm using VS development application server, but doesn't work after creating virtual folder on IIS7.

Coordinator
Oct 12, 2012 at 3:19 AM

first: its not recommended to use office in server scenarios.
okay: you say the open method returns null and no exception occured?
i cant believe it but i dont have any IIS developer experience.
its possible to save a new ccreated worbook in the virtual folder?

Oct 12, 2012 at 4:38 PM

Thank you for the reply.  But customer strongly expect that they can upload doc/docx and ASP.NET can do some simply processing.

After several hours search, I found a blog that mention this issue:

http://www.bloing.net/2011/01/how-to-make-iis7-play-nice-with-office-interop/

 

One of the solution is create "Desktop" folder in a specific folder in windows 2008. It's unbelievable, but it works for me.

Anyway, hope it can help other guys who are working on IIS7 and office programming.