Click here to Skip to main content
15,897,090 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm using the following in an ASP.Net function:

Microsoft.Office.Interop.Excel.Application app = new Application();
double result = app.WorksheetFunction.ChiInv(probability, degreeOfFreedom);
app.Quit();
return result;


The above works fine on my development box. When I publish to the web server and try to run the code I get the following:

Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.UnauthorizedAccessException: Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005.

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true">, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

I've tried following the instructions to no success.

Any ideas how I can get an ASP web page to have access to an excel function?

Thanks!
Don
Posted
Updated 1-Apr-11 15:31pm
v3

Permissions, what a pain. Here are two references that helped me solve the problem.

http://forums.asp.net/p/1045732/1467231.aspx[^]

and

http://forums.asp.net/t/1303594.aspx[^]

Changing the DCOMCNFG identity to "interactive" instead of "launching user" completed the process. I'm now able to access the excel function on our web server.

Don
 
Share this answer
 
Did you look at the stack trace? It says System.UnauthorizedAccessException

Not just it, error details also suggest the resolution:
ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via , the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

Just make sure that proper permissions are given to the account using it. You can try impersonation, if needed.
 
Share this answer
 
Thanks for the reply. I've tried giving permissions. I must not have done that correctly. I'll explore that a bit and see what I come up with.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900