Config dcomcnfg to download Excel file using Microsoft.Office.Interop.Excel library

When I used Microsoft.Office.Interop.Excel library to download excel file from website is hosted in IIS, I received error:
“Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered”.
This is a COM permissions problem. To solve this problem we will follow these steps:
1. Start > Run > dcomcnfg (or “MMC comexp.msc /32″ if Microsoft Office Excel is installed 32bit version) and find Microsoft Excel Application in DCOM Config folder.

2. Right lick Microsoft Excel Application and select Properties

3. In Launch and Activation Permissions panel select Customize option and then click Edit button, so add and set permission for IIS_IUSRS user as picture below
LaunchPermission

4. In Access Permissions panel select Customize option and then click Edit button, so add and set permission for IIS_IUSRS user as picture below
AccessPermissions

5. In Configuration Permission select Customize option and then click Edit button, so add and set permission for IIS_IUSRS user as picture below
ConfigurationPermission

6. In Identity tab, select this user option and enter username and password as picture below.
IdentityUser

Finally click OK.

Happy coding!

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s