Last post Aug 20, 2010 07:13 AM by santosh.jagdale
Aug 18, 2010 11:41 AM|ashok.arumugam|LINK
The problem I am posting here is that I was facing nearly 2 weeks around. Any body comes with this stuff please help.
Word Automation in sample ASP.NET(C#) application.
I am using Microsoft.Office.Inetrop.Word Assembly for automation. Here I am reading a XXX.dot template file and fill the contents with dynamic data.
When i am executing my code in localhost:someportnumber the automation is working fine and I could get expected result and when I am hosting in my
inetmgr(Windows XP is my OS) it is also working fine.
But the problem is that when I am hosting in my production server(Windows Server 2008 Standard Edition) I am not able to perform automation and results in the following error.
Message: Word has encountered a problem.
Source: Microsoft Word
The code gets failed in the following line:
ApplicationClass wordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
Document wordDoc = wordApp.Documents.Add(ref oTemplate, ref oFalse, ref oMissing, ref oMissing); // Error in this line
I cannot able to proceed further. Can anybody please help me in solving this issue?
Aug 18, 2010 04:31 PM|hans_v|LINK
I am using Microsoft.Office.Inetrop.Word Assembly for automation
That's were your problem begins, because you shouldn't use this on a web server:
"Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit
unstable behavior and/or deadlock when Office is run in this environment."
Aug 19, 2010 01:40 AM|ashok.arumugam|LINK
I have already read this link and I am aware of this. My website is accessed only by admin on the server itself. So if anything fails he will be attending it. The code which performs word automation exists in a WCF webservice. This service is called from
ASPX page. As I mentioned before, the code fails in below line
// The code fails at the below line.
Document wordDoc = wordApp.Documents.Add(ref oTemplate, ref oFalse, ref oMissing, ref oMissing);
The same webservice works fine and generated document in Winsows XP machine but it fails in Winsows 2008 server. Windows XP has Word 2007 enterprise version while Windows 2008 server has Word 2007 professional version (build and SP are same). The same code
work fine within windows application but only fails in WCF service. We suspect some configuration or security settings issue. Can you provide what settings did I miss?
Aug 20, 2010 07:13 AM|santosh.jagdale|LINK
If you want to do Server side Office automation better you go with OpenXML SDK.