简体   繁体   中英

Office Interop access denied when access is

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?

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, eg {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..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM