做了一将dataset里的数据导出到excel功能,本地运行一切正常,发布到服务器上提示出错(服务器上office已经安装过),错误信息如下,Server Error in '/' Application.
--------------------------------------------------------------------------------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.Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  请问如何解决,谢谢

解决方案 »

  1.   

    服务器上是不是没有注册你用到的dll,比如OWC11.DLL  运行中 regsvr32 注册
      

  2.   

    ASP.NET 导出Excel 80070005错误解决备忘
    检索 COM 类工厂中 CLSID 为{00024500-0000-0000-C000-000000000046} 的组件时失败,原因是出现以下错误: 80070005。  
    具体解决方法如下:  
    1:在服务器上安装office的Excel软件.  
    2:在"开始"->"运行"中输入dcomcnfg.exe启动"组件服务"  
    3:依次双击"组件服务"->"计算机"->"我的电脑"->"DCOM配置"  
    4:在"DCOM配置"中找到"Microsoft Excel 应用程序",在它上面点击右键,然后点击"属性",弹出"Microsoft Excel 应  
    用程序属性"对话框  
    5:点击"标识"标签,选择"交互式用户"  
    6:点击"安全"标签,在"启动和激活权限"上点击"自定义",然后点击对应的"编辑"按钮,在弹出的"安全性"对话框中填加  
    一个"NETWORK SERVICE"用户(注意要选择本计算机名),并给它赋予"本地启动"和"本地激活"权限.  
    7:依然是"安全"标签,在"访问权限"上点击"自定义",然后点击"编辑",在弹出的"安全性"对话框中也填加一个"NETWORK  
    SERVICE"用户,然后赋予"本地访问"权限.  
    这样,我们便配置好了相应的Excel的DCOM权限.  
    注意:这是在WIN2003上配置的,在2000上,可能是配置ASPNET用户  
    由于EXCEL是在服务器上打开的,所以应该写一个把导出数据保存在服务器上,然后再传递给客户端的方法,最后每次调  
    用这个功能的时候再删除以前在服务器上所生成的所有Excel  
       
    方案2  
    在创建 EXCEL 应用程序时出现错误:
    检索 COM 类工厂中 CLSID 为 {00024500-0000-0000-C000-000000000046} 的组件时失败,原因是出现以下错误: 80070005
    解决办法: 配置 DCOM 中 EXCEL 应用程序:
    要在交互式用户帐户下设置 Office 自动化服务器,请按照下列步骤操作:  
    1.
    以管理员身份登录到计算机,并使用完整安装来安装(或重新安装)Office。为了实现系统的可靠性,建议您将 Office CD-ROM 中的内容复制到本地驱动器并从此位置安装 Office。  
    2.
    启动要自动运行的 Office 应用程序。这会强制该应用程序进行自我注册。  
    3.
    运行该应用程序后,请按 Alt+F11 以加载 Microsoft Visual Basic for Applications (VBA) 编辑器。这会强制 VBA 进行初始化。  
    4.
    关闭应用程序,包括 VBA。  
    5.
    单击开始,单击运行,然后键入 DCOMCNFG。选择要自动运行的应用程序。应用程序名称如下所示:  
    Microsoft Access 97 - Microsoft Access 数据库
    Microsoft Access 2000/2002 - Microsoft Access 应用程序
    Microsoft Excel 97/2000/2002 - Microsoft Excel 应用程序
    Microsoft Word 97 - Microsoft Word Basic
    Microsoft Word 2000/2002 - Microsoft Word 文档  
    单击属性打开此应用程序的属性对话框。  
    6.
    单击安全选项卡。验证使用默认的访问权限和使用默认的启动权限已选中。  
    7.
    单击标识选项卡,然后选择交互式用户。  
    8.
    单击确定,关闭属性对话框并返回主应用程序列表对话框。  
    9.
    在 DCOM 配置对话框中,单击默认安全性选项卡。  
    10.
    单击访问权限的编辑默认值。验证访问权限中是否列出下列用户,如果没有列出,则添加这些用户:  
    SYSTEM
    INTERACTIVE
    Everyone
    Administrators
    IUSR_<machinename>*
    IWAM_<machinename>*
    * 这些帐户仅在计算机上安装了 Internet Information Server (IIS) 的情况下才存在。  
    11.
    确保允许每个用户访问,然后单击确定。  
    12.
    单击启动权限的编辑默认值。验证启动权限中是否列出下列用户,如果没有列出,则添加这些用户:  
    SYSTEM
    INTERACTIVE
    Everyone
    Administrators
    IUSR_<machinename>*
    IWAM_<machinename>*
    * 这些帐户仅在计算机上安装有 IIS 的情况下才存在。  
    13.
    确保允许每个用户访问,然后单击确定。  
    14.
    单击确定关闭 DCOMCNFG。  
     
    如果你之前起用了身份模拟 (在 web.config 中配置了 <identity impersonate="true"/> ) ,需要删除之!...
      

  3.   

    或者
    <system.web>
        <identity impersonate="true" userName='administrator' password='...'/>