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

后端 未结 10 1145
无人及你
无人及你 2020-11-27 16:01

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

相关标签:
10条回答
  • 2020-11-27 16:32

    This one was sticky for me to figure out, maybe my Windows mojo skills are just sub-par. But I could not get Component Services to run in 32 bit mode on Windows Server 2008. Hopefully this can help someone else with the same problem:

    1. Run Component Services by either method previously mentioned (Run box or Administrative Tools); close this program
    2. Paste "C:\Windows\System32\mmc.exe" /32 into the Run box and hit Enter (verify in Task Manager that you see mmc.exe *32)
    3. Go to File and you should see comexp.msc in the list (because of step 1), select it and it'll open Component Services in your 32 bit mode MMC console.

    EDIT: just for completeness sake, in order to get Word Interop working on Windows Server 2008 I also had to create the Desktop folder as outlined in this answer.

    0 讨论(0)
  • 2020-11-27 16:34

    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!
    0 讨论(0)
  • 2020-11-27 16:36

    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.

    0 讨论(0)
  • 2020-11-27 16:37

    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.

    0 讨论(0)
  • 2020-11-27 16:38

    Fix to Tomas answer, correct command on Windows Server 2k8 x64 is: "dcomcnfg /32" (slash instead of -)

    Also I had to customize all security options by adding IIS_IUSRS with full rights to Lunch and Activation Permissions, Access Permissions and Configuration Permissions. And Interactive user in Identity tab as well. Then it worked for me.

    I had this problem with Word 2010 opening doc files and I had to set it for Microsoft Word 97-2003 Document Properties.

    0 讨论(0)
  • 2020-11-27 16:39

    I had the same problem, finally was because my user didn't have permission to run the service "Remote Procedure Call(RPC)". In control panel, Administrative tools, I looked for that service and in Log On I clicked in "Local System Account", I restarted the system and problem solved.

    0 讨论(0)
提交回复
热议问题