System.UnauthorizedAccessException: Retrieving the COM class factory for Word Interop fails with error 80070005

Here is my fix for this problem:

I'm using Win 7 64bit and Office 2007

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".

Do not forget to press "OK" when done. :D

I Hope this helps you with your problem and also the rest who gets here and read this.


You should grant an access to Word COM component for ASP.NET process identity ({MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6):

"Control Panel - Administrative Tools - Component Services - Computers - My Computer - DCOM Config"

Find out "Microsoft Word Document", right click - Settings - Security Tab, grant access (local and remote) for ASP.NET process identity ("ASPNET" for IIS 5, "Network Service" for IIS 6).


If then you get an "System.Runtime.InteropServices.COMException (0x800A13E9): There is insufficient memory. Save the document now." exception when open/add document (my own expirience), just delete temporary files from %Temp% and \Content.Word folders.


launching dcomcnfg -32 or dcomcnfg /32 both failed to show the target app (Microsoft Excel) in the list.

But my following the directions @ How to make IIS7 play nice with Office Interop, in particular, the note about launching mmc -32 and manually adding in the Component Services snap-in, I was able to get it to appear. (NOTE: although the link talks about IIS7, my issue was with a Windows service).

  1. Start > Run > dcomcnfg (or “mmc -32″ and then add the Component Services snap-in manually if you can’t find the app under step 3)
  2. Navigate to Component Services > Computers > My Computer > DCOM Config
  3. Locate the MS application giving you trouble (eg: “Microsoft Excel Application” for Excel or “Microsoft Word 97 – 2003 Document” for Word)
  4. Right click > Properties
  5. On the security tab: Select Customize under Launch and Activation Permissions and click Edit…
  6. Add the account under which the site is running (eg: Network Service) and assign Local Launch & Local Activation permissions
  7. Voila!

Tags:

C#

.Net

Windows 7