在IIS 7上使用Excel对象会导致COM类失败 [英] Using excel object on IIS 7 causes COM class failure

查看:96
本文介绍了在IIS 7上使用Excel对象会导致COM类失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ASP.Net函数中使用以下代码:

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;



上面的工作在我的开发箱上很好.当我发布到Web服务器并尝试运行代码时,我得到以下信息:

由于以下错误,检索具有CLSID {00024500-0000-0000-C000-000000000046}的组件的COM类工厂失败:80070005.

说明:执行当前Web请求期间发生未处理的异常.请查看堆栈跟踪,以获取有关错误及其在代码中起源的更多信息.

异常详细信息:System.UnauthorizedAccessException:检索具有CLSID {00024500-0000-0000-C000-000000000046}的组件的COM类工厂失败,原因是出现以下错误:80070005.

没有授权ASP.NET访问请求的资源.考虑将资源的访问权限授予ASP.NET请求标识. ASP.NET具有一个基本进程标识(在IIS 5上通常为{MACHINE} \ ASPNET或在IIS 6上通常为Network Service),如果应用程序无法模拟,则可以使用该标识.如果应用程序正在通过< identity impersonate ="true">进行模拟,则该身份将是匿名用户(通常为IUSR_MACHINENAME)或已认证的请求用户.

要授予ASP.NET对文件的访问权限,请在资源管理器中右键单击该文件,选择属性",然后选择安全性"选项卡.单击添加"以添加适当的用户或组.突出显示ASP.NET帐户,然后选中所需访问权限的框.

我尝试按照指示进行操作,但未成功.

关于如何获取ASP网页以访问excel功能的任何想法吗?

谢谢!
Don



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

推荐答案

权限,真是麻烦.这里有两个参考资料可以帮助我解决问题.

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



http://forums.asp.net/t/1303594.aspx [
Don
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


您是否看过堆栈跟踪?它说System.UnauthorizedAccessException

不仅如此,错误详细信息还建议解决方法:
ASP.NET无权访问所请求的资源.考虑将资源的访问权限授予ASP.NET请求标识. ASP.NET具有一个基本进程标识(在IIS 5上通常为{MACHINE} \ ASPNET或在IIS 6上通常为Network Service),如果应用程序无法模拟,则可以使用该标识.如果应用程序通过进行模拟,则身份将是匿名用户(通常为IUSR_MACHINENAME)或经过身份验证的请求用户.

只要确保为使用该帐户的帐户分配了适当的权限即可.如果需要,您可以尝试模拟.
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.


感谢您的回复.我尝试授予权限.我一定不能正确地做到这一点.我将对此进行一些探讨,然后看看我的想法.
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.


这篇关于在IIS 7上使用Excel对象会导致COM类失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆