DCOM Automation Control Error

I developed a C # program that extracts data from a SQL Server database and then creates Word documents that include data. I installed the program to run as part of the SSIS job in a Windows Server 2003 window. The program runs as a SQLSVC user who does not have administrative privileges. When I log in as SQLSVC and run the program, it runs correctly. However, when the program starts automatically as an SSIS job, it freezes in the next line of code

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

When I force a process kill, 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 understand, the problem is with DCOM permissions. I used dcomcnfg to add all the possible DCOM permissions for the SQLSVC user, but that didn't help. Are there other possible solutions?

+4
source share
4 answers

Run the program "dcomcnfg -32". (You cannot find the word and excel components if it works under 64 bits) Go to the section "Root Console / Component Services / Computer / My Computer / DCOM Config /" Look at Microsoft Word and Excel and select the properties. Go to the Security section and select "Configure" in the "Configuration Permissions" section. (If necessary, you can also change other permissions, but I did not need to add "IIS_IUSRS" and give it "Full Control"). Now go to "Identity" and select "Interactive User."

+6
source

A few things here.

Firstly, this SO thread can help.

Secondly, Microsoft warns that "complications" may arise when automating Office through an automatic process. Here's the poeling (shown in bold in the original):

Microsoft currently does not work to recommend and does not support, Automating Microsoft Office applications from any automated, non-interactive client application or component (including ASP, ASP.NET, DCOM and NT Services), because Office may exhibit unstable behavior and / or deadlocks when Office is running in this environment.

A related article discusses workarounds.

+4
source

It depends on whether you work on a 64-bit machine, and if you are a 32-bit office or a 64-bit office, but in any case you need to go to "Administrator Tools"> "Component Services" and in the DCOM configuration you need search for "Microsoft Word 97 - 2003 Document," and then set "identity" for the user who is running your application pool. or just unplug it.

If you are using a 64-bit server with 32-bit Office, you may not be able to find this DCOM setting. You will need to run “MMC-32” from the command line to start the 32-bit MMC, and then add “Component Services” from the menu “File”> “Add and Remove Snap-ins”.

Hope this helps

+3
source

One point on my part, I was planning a batch job on one of our servers, and it gave the same error while it was working on my local server.

I tried all of the above steps, but in my case the real scenario was different.

When planning batch work, do not select the [Run regardless of whether the user is logged in or not] option, as this requires administrator access, and if not, you have problems.

enter image description here

0
source

Source: https://habr.com/ru/post/924733/


All Articles