2
votes

I have created console application in C# to read a Excel file. Used microsoft interop dll to manipulate excel file. The excel file is created in Excel 2013. .net version is 4.5 OS : windows server 2012

It will open the excel file and add a row sheet with values.

The functionality is working fine. But when I configure the exe in task scheduler I am getting an error.

Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).

Also I have tried to run the exe in command prompt with the same user credential which was used to configure the task in scheduler.

My Question is, the exe working fine in the command prompt but not working in task scheduler.

Any thoughts??

1

1 Answers

2
votes

Option1:

Try the following steps

  1. In DCOMCNFG, right click on the My Computer and select properties.
  2. Choose the COM Securities tab
  3. In Access Permissions, click "Edit Defaults" and add Network Service to it and give it "Allow local access" permission. Do the same for \Users.
  4. In launch and Activation Permissions, click "Edit Defaults" and add Network Service to it and give it "Local launch" and "Local Activation" permission. Do the same for \Users

Have a look into this link if there any permission problems

Option 2:

if you can't find the reason, just switch your solution as Save AS method