DCOM Failure of Office Automation

Eric Ness picture Eric Ness · Nov 6, 2009 · Viewed 18.7k times · Source

I developed a C# program that pulls data from a SQL Server database and then generates Word documents which include the data. I've set the program up to run as part of an SSIS job on a Windows Server 2003 box. The program runs as user SQLSVC which doesn't have administrative privileges. When I log in as SQLSVC and run the program it executes correctly. However, when the program is run automatically as an SSIS job it freezes at the following line of code

Microsoft.Office.Interop.Word.Application word =
    new Microsoft.Office.Interop.Word.Application();

When I kill the process forcibly, the following error message is generated.

Error Message: System.Runtime.InteropServices.COMException (0x80080005):
Retrieving the COM class factory for component
with CLSID {000209FF-0000-0000-C000-000000000046}
failed due to the following error: 80080005.
   at IepGlance.Program.CreateNewIepFiles(Dictionary`2
       iepDictionary, EasyIepDataContext dbContext)
   at IepGlance.Program.Main(String[] args)

As far as I can figure out the problem is with DCOM permissions. I've used dcomcnfg to add all possible DCOM permissions to user SQLSVC, but this hasn't helped. Are there any other possible solutions?

Answer

Juny Eldo picture Juny Eldo · Dec 1, 2014

Run program "dcomcnfg -32". ( You cant find the word and excel components if it runs under 64bit) Go to "Console Root/Component Services/Computer/My Computer/DCOM Config/" Look up Microsoft Word and Excel and choose properties. Go to Security and select "Customize" under "Configuration Permissions. (If needed you might want to change the other permissions as well, but I didn't need to) Add "IIS_IUSRS" and give it "Full Control". Now go to "Identity" and select "The interactive user".