Diligent achievement genius ...

业精于勤荒于嬉 行成于思毁于随 voiow博客
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Server.CreateObject 的调用失败

Posted on 2010-10-16 18:53  voiow  阅读(767)  评论(0编辑  收藏  举报

一个简单的例子,Web从excel中读取内容:

<%

Set xlApp = server.CreateObject("Excel.Application")

strsource = "f:\1dw\cl\汉字库.xls"

Set xlbook = xlApp.Workbooks.Open(strsource)
Set xlsheet = xlbook.Worksheets(1)

i=1
response.write "<table cellpadding=0 cellspacing=0 border=1 width=500>"
while xlsheet.cells(i,1)<>""

response.write "<tr>"
response.write " <td height=20 align=center width=100>" & xlsheet.Cells(i, 1) & "</td>"
response.write " <td height=20 align=center width=200>" & xlsheet.Cells(i, 2) & "</td>"
response.write " <td height=20 align=center width=200>" & xlsheet.Cells(i, 3) & "</td>"
response.write "</tr>"
i=i+1

wend
response.write "</table>"
set xlsheet=nothing
set xlbook=nothing
xlApp.quit

%>

运行,产生错误

错误类型:
Server 对象, ASP 0178 (0x80070005)
检查权限时,对 Server.CreateObject 的调用失败。拒绝对此对象的访问。

参考网上的方法,摸索以下步骤:

管理工具-->组件服务-->计算机-->我的电脑-->DCOM配置

1.选择Microsoft Excel 应用程序 -->属性

标识:选择交互式用户

安全:启动和激活权限-->自定义,加入InterNet来宾帐户,勾上本地启动和本地激活

2.选择Microsoft Office Excel 2007 工作簿 -->属性

常规:身份验证级别 -->无


有人电脑无DCOM配置的属性,解决方法(已验证)

确保下面四个服务是开着的话,那就能确保右键的属性能够出现。
1、Remote Procedure Call (RPC)
2、COM+ Event System
3、DCOM Server Process Launcher
4、Distributed Transaction Coordinator

然后再进入组件服务,就能在DCOM配置中看到右键的属性了,并且组件服务计算机中的"我的电脑"上的那个红色的向下箭头也消失了。

Distributed Transaction Coordinator 服务因 3221229584 (0xC0001010) 服务性错误而停止这个错误,主要是系统无法找到MS DTC 日志文件造成的,只要创建一下就可以了:开始-运行-输入命令"msdtc -resetlog"

然后再启动该服务就可以了