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

Viewed 82705

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 (x64). 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

11 Answers

I test all above methods that also marked as answer but in windows server when user is not active or logoff, get access exception. so:

  1. I created a user on local computer and add it to two group: IIS_USER and Administrator
  2. Component Services -> Computers -> My Computer -> DCOM Config
  3. In com+ object i change to run Microsoft Word 97 – 2003 Document component with this user. See it here
  4. also add IIS_USER and also Application-identity user (IIS APPPool\[Name]) to all three section on security section and make the full permission as possible. See it here

office will run with settings from user that you create in first step, so if you change any setting with this user. 120% Working with no problem. tried over 3 different server.

Go to registry HKCR>TypeLib>{00020905-0000-0000-C000-000000000046}>8.7>0, then delete the folder "win32" this is for Word COM Class error.

Go to registry HKCR>TypeLib>{00020813-0000-0000-C000-000000000046}>1.9>0, then delete the folder "win32" this is for Excel COM Class error.

Try that method that method fixed my problem.

I created the folder C:\Windows\System32\config\systemprofile\desktop , that fixed my problem that my Service couldn't open Excel files.

Related