Thursday, April 2, 2015
0 comments

Configure Office Application dll on windows server 2008R2 and 2012(ERROR – RETRIEVING THE COM CLASS FACTORY FOR COMPONENT WITH CLSID {00024500-0000-0000-C000-000000000046} FAILED DUE TO THE FOLLOWING ERROR: 80070005 ACCESS IS DENIED. (EXCEPTION FROM HRESULT: 0X80070005 (E_ACCESSDENIED))).

4:11 PM

Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))



  • Install Interop Assemblies: make sure either Microsoft office installed  with .NET Programmability Support feature selected or install the assemblies directly from microsoft website.
  • Assemblies Version: check the version of the assemblies on development and production machines, the assemblies will be in the GAC, in widows 7 this folder is %windir%\assembly. of course the versions should match.
  • Desktop Folder: the service uses the desktop folder under systemprofile so you will need to create this folder if not there, here is the location of the folder:
    • For 64 bit applications : C:\Windows\SysWOW64\config\systemprofile\Desktop
    • For 32 bit applications : C:\Windows\System32\config\systemprofile\Desktop
  • DCOM Running User and Permissions: you need to find the excel application entry in the component services console and set the security and identity for it:
    1. First if the user running the service is a domain user make sure it’s added as a user on the server machine.
    2. In the run window type dcomcnfg.
    3. Expand Component Services –> Computers –> My Computer –> DCOM Config.
    4. look for Microsoft Excel Application or CLSID {00024500-0000-0000-C000-000000000046}, if you can’t find it then it’s possible that you are running 32 bit office over 64 bit machine, look at the end of the post for steps to find it.
    5. right click the item and select properties, then select the Security tab.
    6. select Customize for Launch and Activation Permissions and Access Permission and add the user running the service then give it full access.
    7. go to the Identity tab and select This User option and add the user running the service then type it’s password.
    8. click Ok then restart your service.
this step should do it for you, if not you can try the next one.
  • COM Security: you need to set the permission explicitly for the user running the process, here is how to do it:
    1. In the run window type dcomcnfg.
    2. expand Component services –> Computers  then right click on My computer and select Properties.
    3. Select COM security tab and in the Launch and Activation permissions panel click Edit Defaults.
    COM Security
  • add the user executing the service and give it Local Launch and Local Activation permissions.
  • Quit Application: this might not be so much relative but make sure you release the instance of Excel.Applicationobject in your code using the Quit() method, this way your process will not lock the file.
*If you couldn’t find the excel application in the DCOM config then try to find it in the 32 bit console as following:
  • in the run window type mmc -32.
  • go to file and select Add/Remove Snap in…
  • Select component services and click Add.
  • click OK then continue from point number 2 above.


0 comments:

 
Toggle Footer