Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word Interop Issue

Status
Not open for further replies.

tjherman

Programmer
Jun 19, 2006
68
US
I have a problem in deploying an ASP.NET web project with Microsoft.Interop.Word.

From the developing PC, my program opens a Word template, replaces bookmarks with some text from the web page and then saves and closes the file. As many others say, it works fine from the developing PC but when I try to put is on the web server, it fails with the error:
- - - - - -
Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 8000401a.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 8000401a.

Source Error:

Line 185: Dim word As New Microsoft.Office.Interop.Word.Application
Line 186: Dim wobj As Microsoft.Office.Interop.Word.Document
Line 187:
- - - - - - -

The server is running Windows Server 2003. I have tried setting the DCom permissions (on the component labeled My Computer) so that the ASPNET, INTERACTIVE and NETWORK SERVICE accounts have Launch and Activation permissions. I have also gone to the Microsoft Document component under DCom and added the same permissions. My DCom settings for the Word document are to run as Interactive User, authentical level to “Connect”, Location to “Run application on this computer”. I have tried adding permissions to the Assembly folder underneath Windows and have checked the registry to ensure that DCom was enabled.

I’m really at a loss here. Does anyone have any suggestions? This ran flawlessly when it was deployed on a Windows 2000 server back in the fall.
 
From what I've seen, this error usually occurs when the DCOM settings haven't been added you've set the correct settings. Are you doing any impersonation in your application (i.e. could it be that the impersonated user doesn't have the DCOM settings)?


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244 on how to get better results.
 
No, I've got impersonating set to false. There is an error that throws in the event logs. Here's the text of it:
- - - - - - -
Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 3/20/2007 3:36:19 PM
Event time (UTC): 3/20/2007 8:36:19 PM
Event ID: 32831686fad740a78f11771c9fb23964
Event sequence: 25
Event occurrence: 1
Event detail code: 0

Application information:
Application domain: /LM/W3SVC/544506872/ROOT/smart-1-128188964062984752
Trust level: Full
Application Virtual Path: /*****
Application Path: *:\****\***\***\
Machine name: *****

Process information:
Process ID: 3600
Process name: w3wp.exe
Account name: NT AUTHORITY\NETWORK SERVICE

Exception information:
Exception type: HttpUnhandledException
Exception message: Exception of type 'System.Web.HttpUnhandledException' was thrown.

Request information:
Request URL: Request path: /smart/Client/Proposal.aspx
User host address: ***.***.***.**
User: 0023005
Is authenticated: True
Authentication Type: Forms
Thread account name: NT AUTHORITY\NETWORK SERVICE

Thread information:
Thread ID: 1
Thread account name: NT AUTHORITY\NETWORK SERVICE
Is impersonating: False
Stack trace: at System.Web.UI.Page.HandleError(Exception e)

at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

at System.Web.UI.Page.ProcessRequest()

at System.Web.Util.AspCompatApplicationStep.System.Web.HttpApplication.IExecutionStep.Execute()

at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

- - - - - -

Does this give any other clues?
 
All it shows is that it is the NETWORK SERVICE account that doesn't have the correct permissions (which presumably means it is a windows 2003 machine). I've done this before and only had to give Launch/Execute permissions to this user in the DCOM seetings (however, this was for Excel and not Word so maybe there is a different entry you need to set?).


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244 on how to get better results.
 
Yes, I've given Launch and Activate to Network Service both at the top Dcom level and also on the Microsoft Document. It does seem like it's a security issue but I don't know what else to give this account permissions to. I've also given this user rights to the folder where the Word template that it's trying to open is stored, to the Winword.exe file, to the Assembly folder, and within the registry on the HKEY Classes Root/Office/Word Document.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top