当前位置: 代码迷 >> ASP.NET >> 在Asp.Net中访问Excel组件权限有关问题
  详细解决方案

在Asp.Net中访问Excel组件权限有关问题

热度:2868   发布时间:2013-02-25 00:00:00.0
在Asp.Net中访问Excel组件权限问题
我在Asp.net程序是用到了访问Excel组件,一本机运行正常。但上传到服务器后出现了如下错误:
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.

说明:我已对服务器dcom进行了如下配置,:
  (1)打开开始菜单的运行对话框,输入dcomcnfg命令,确定,这时会弹出组件服务窗口      
    (2)展开计算机-〉我的电脑-〉DCOM配置,找到Microsoft       Excel应用程序节点      
    (3)单击右键-〉属性,选中“安全”选项,在下面三个项目都选择“自定义”,并单击编辑按钮      
    (4)在启动权限对话框中点击添加按钮,添加相应的用户(注意:如果是WIN2000,XP,则添加“机器名/ASPNET”用户,
我这里是以WIN2003为例,WIN2003是添加“NETWORK       Service”用户),并赋予最大权限      

请高手们帮助分析一下是什么原因

------解决方案--------------------------------------------------------
office com 没有权限
------解决方案--------------------------------------------------------
虚拟一个帐户吧
在web.config里
------解决方案--------------------------------------------------------
解决办法:
第一步:登录服务器
1,开始-运行:输入dcomcnfg.exe
2,选择excel应用程序点击属性
3,启动/访问授予aspnet用户和network
4,身份标识选择指定用户输入用户名/密码,确认关闭 ----(主要是这句)
第二步:打开服务器模板文件所在文件夹右击选择属性安全
添加用户aspnet,administrator
  相关解决方案