2012-12-15 96 views
3

我使用Windows XP_SP_3和IIS 5(本地主机),建立网站与ASP.NET4,并使用此代码:检索COM类工厂CLSID组件{000209FF-0000-0000-C000-000000000046}

Application appClass = new Application(); 
Document wordDoc = appClass.Documents.Add(Server.MapPath("~") + @"Files\tmp.docx"); 
wordDoc.SaveAs(@"e:\hp\Files\" + TextBox1.Text + ".docx"); 
wordDoc.Close(); 

如果用VS2010运行网站,那就OK。但如果与IIS 5(本地主机)上运行,显示此错误:

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

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 {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).

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 and IIS 7, and the configured application pool identity on IIS 7.5) 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.

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.


我打开组件服务>计算机>右键点击我的电脑>选择属性> COM Sucrity>启动和激活... >编辑默认值>添加>高级>

我找不到用户IIS(IIS_IUSRS)。所以选择ASP.NET和确定并检查本地启动&远程启动&本地激活&远程激活。

rest系统再次运行iis5站点。但再次显示错误!

+0

你处于死路一条。 http://support.microsoft.com/kb/257757 –

回答

0

启动Internet信息服务(IIS)。 用鼠标右键单击您的应用程序的虚拟目录,然后单击属性。 单击目录安全性选项卡。 在匿名访问和身份验证控制下,单击编辑。 确保未选中“匿名访问”复选框,并且“集成Windows身份验证”是唯一选中的复选框。 配置ASP.NET使用Windows身份验证与模拟,请使用以下配置

... 
<authentication mode="Windows"/> 
<identity impersonate="true"/> 
... 

4
  1. 转到控制面板 - >管理工具 - >组件 服务
  2. 展开树通过点击组件服务 - > 电脑 - >我的电脑 - > DCOM配置
  3. 搜索CLSId 00020906-0000-0000-C000-000000000046(用于word应用程序) 注意:如果搜索CLSId未找到,则通过“Windows Word应用程序”进行搜索。
  4. 通过选择 00020906-0000-0000-C000-000000000046此CLSID现在右击属性
  5. 在化子性质区域中,单击安全选项卡。
  6. 选择全部自定义选项(启动和激活 权限,访问权限,配置权限)。
  7. 添加新名称为网络服务,并允许所有权限为 这个名称。
  8. 转到身份标签在相同的属性区域,选择 选项作为此用户,然后添加用户名(这是 管理员本机)和密码。点击应用,确定。
  9. 刷新组件服务并检查您的应用程序是否正在工作 是否正常。
+0

它的工作,有趣,我想知道为什么从错误信息给出的CLSID不匹配此ID ... – jarvanJiang

+0

如果搜索CLSId没有找到,然后搜索“ Windows Word应用程序“。搜索CLSId根据Windows版本而有所不同。 –

相关问题