tags:

views:

1555

answers:

6

Hello.

I have a problem with a C# ASP .NET project in Visual Studio 2008 This problem started when I reinstalled my computer with Windows 7 ultimate 64-bit. To this I'm also using Office 2007.

The error message I'm getting is:

{System.UnauthorizedAccessException: Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005. at xxx.Utility.WordDocument..ctor(String filePath, HttpServerUtility util) at customer_communication.BuCreate_click(Object sender, EventArgs e) in c:\xxx\Website\customer\communication.aspx.cs:line 127}

If anyone can help me I would rely appreciate it.

A: 

This error corresponds to .NET System.UnauthorizedAccessException and is usually caused by wrong settings for access on COM component your code tries to create.

You may try to start dcomcnfg utility, go to DCOM settings, select required object and allow access to it for the account your ASP.NET code runs under. It should solve your problem.

elder_george
This is true, but if your running Windows 7 64bit, you have to start dcomcnfg as 32bit: "dcomcnfg -32".If you dont, you wont find the Word or Excel to set the permissions
Tomas I
A: 

Hi there, Did you ever got the solution to this issue. I've been having a same issue and not able to find a solution.

Siraj
A: 

Sorry for giving you a short and not so helping answer...

I did fix my problem in a bad way. Since it was on my developing machine I set full rights to everything on my computer. I never took the time to really sort it out.

Im a little busy at the moment, but Ill try to take the time to back step what I did to make it work.

Tomas I
+2  A: 

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.

SergeanT
I had the same problem but couldn't find "Microsoft Word Document" in DCOM Config.
Larry Watanabe
"Microsoft Word Document" is localized with your MS Office language. In Russian, for example it is named "Документ Microsoft Word". Also you can try to find it by CLSID {000209FF-0000-0000-C000-000000000046} in the right column (use table view).
SergeanT
A: 

Hi, I am also getting the same error when my web service tries to open MS word document programatically. When I run web service through visual studio, it worked fine but when I deployed web service on IIS 7, I got the error

Retrieving the COM class factory for component with CLSID {00020906-0000-0000-C000-000000000046} failed due to the following error: 80070005

I have tried to change DCOM setting using dcomcnfg command and I have added 'Network Service', 'Network' users. I have added my own user id also in 'Microsoft Word Document' component properties and given them full permission. I have also added impersonate=true property in web.config. After doing all this also I am getting same error. Can anyone please help me out?

Shekhar
Are you still getting 80070005 error code, or this code has changed?
SergeanT
@SergeanT, yes, still I am getting the same error code. As I have mentioned this error comes only when I try to invoke word from my web service. Is there any particular reason behind this behaviour?
Shekhar
Try to set back `impersonate=false`, grand access for `NETWORKSERVICE` and enable `anonymousAuthentication`. Refer to [Changes Between IIS 6.0 and IIS 7 Security](http://learn.iis.net/page.aspx/110/changes-between-iis-60-and-iis-7-security/)
SergeanT
Also IIS 7 uses `<system.webServer>` section in web.config, maybe problem with configuration there.
SergeanT
A: 

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.

Tomas I