1
votes

I try convert Office documents using Office.Interop running under separate Windows service. This service is running under specific account (username in future).

All folder access rights is set for this account. And when i try to create any of Office application (for example, var app=new Excel.Application()) then my code fails with exception:

Retrieving the COM class factory for component with CLSID {XXXX} failed due to the following error: E_ACCESSDENIED.

Ok, but i have already configured the DCOM permissions for this CLSID! I open the dcomcnfg.exe , select component with this CLSID, opening settings, security and see that user of this service have all rights for this component.

Why this exception throws?

1
I don't think that you can (edit: should) use Office stuff from within a service. The commercial Aspose company has some more in-depth about why.Uwe Keim
@UweKeim Sure you can use Office interop within a window service.Letseatlunch
@UweKeim Yes, you can! We sell software that includes that. But it is not supported by microsoftT.S.
We had similar issue long time ago. I forgot exactly but ended up that we needed to logon into office-running machine as the user that service "runs as"T.S.
Which account is the service using? Local System?Matt

1 Answers

0
votes

Ocka guys, i found the answer. 1) Be sure that you have install a right version of Office 2007 2) Be sure that you have install a PDF\XPS addin 3) Just office and its addin installed, you should run DCOMCNFG and pick My Computer->DCOM config. As it turned out, after office installation there is no mappings between CLSID and AppID in registry. 4) Close dcomcnfg window. Now there is right mappings in registry. You should get all things related to office (its id, e.g. {XXXXXXX-XXXX...}) in HKCR\AppID and HKCR\CLSID 5) For all these id's you should grant access, this can be achieved using this algorythm: * open HKCR\AppID{id} key * setup LaunchPermission and ActivatePermission values (code to do this find there in stackoverflow) * Set value "RunAs" as "Interactive User"

Ocka, your office automation should work correctly, if i didn't forget some step..