Skip to content

Instantly share code, notes, and snippets.

@jtlimson
Last active August 9, 2024 13:05
Show Gist options
  • Save jtlimson/a9b54a138479b37aabdf61ccebec7f5b to your computer and use it in GitHub Desktop.
Save jtlimson/a9b54a138479b37aabdf61ccebec7f5b to your computer and use it in GitHub Desktop.
Microsoft Office Interop Related Issues.

Microsoft Office Interop Related Issues during IIS deployment

80070005 Access denied

This error basically means that the web site is definitely finding the COM objects related to the MS Office application you want to execute, but the Application Pool in charge of the running process doesn’t have permissions to use them. In order to fix that, follow these steps:

  • Open IIS Manager > Application Pools and identify the identity assigned to the Application Pool assigned to the web application (it’s in the Advanced Properties tab). Keep a note of that user (or system) account, because you’ll need it later on. If you fond the ApplicationPoolIdentity there, you need to do some little extra-work: as you might know, that user it’s a dynamically created, unprivileged account: to change its permissions in the following steps, you’ll need to look-up for the IIS AppPool[AppPoolName] role. If that’s too much for you to handle, you can change the identity to a “static” account… but you shouldn’t do that, as the ApplicationPoolIdentity usage is a best practice to deal with IIS7+ / IIS8+ Application Pools in a secure way. For additional info on that topic, read this StackOverflow thread.

  • Launch the dcomcnfg command from Windows > Start > Run or from a command-prompt: go to Component Services > Computers > My Computer > DCOM Config, then locate the various “Microsoft XYZ Document” and/or “Microsoft XYZ Application” entries, where XYZ are Word, Excel and/or Access – depending on what you need to access programmatically from your ASP.NET web application: you’ll need to perform the following tasks for each one of them.

  • Right-click the entry and select Properties: Go to the Identity tab, where you’ll see three radio buttons:

    • The Interactive User, The Launching User and This User. Select This User, then put the credentials of the account who installed MS Office – or an administrative account.
    • Go to the Security tab, where you’ll find three group boxes: for the first two of them – Launch and Activation Permissions and Access Authorization – select the Customize radio button, then add the same identity that runs your web site’s Application Pool – the one which you took note of few minutes ago. In some scenarios, depending on the Windows Server version, you’ll also need to add the IUSR and IUSR_[MACHINENAME] accounts.

IMPORTANT: in case the DCOM Config panel does not contain any “Microsoft XYZ Document” and/or “Microsoft XYZ Application“, it’s most likely due to the fact that a 32-bit MS Office version has been installed on a 64-bit server machine: if that’s the case, we’ll need to launch the snap-in in 32-bit mode by using the following command:

> mmc comexp.msc /32

0x800A03EC Cannot access the file

The 0x800A03EC Cannot access the file is arguably the worst error you can experience, as the given error message is completely misleading. To fix that, you have to the following:

  • Create the following new folders on your Windows Server + IIS machine:
    • C:\Windows\SysWOW64\config\systemprofile*Desktop* (for 64-bit Servers only)
    • C:\Windows\System32\config\systemprofile*Desktop* (for both 32-bit and 64-bit Servers)
  • Set Full control permissions for these Desktop folders for the Application Pool user (IIS AppPool\DefaultAppPool if you’re using the ApplicationPoolIdentity dynamic account). That’s it for now: I sincerely hope that this post will help most developers who’re struggling against the adversities of the dreadful Microsoft.Office.Interop ASP.NET library package!

reference : https://www.ryadel.com/en/office-interop-dcom-config-windows-server-iis-word-excel-access-asp-net-c-sharp/

@SteveDek
Copy link

It worked! Thank you!

@kellyfire611
Copy link

Worked, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment