微软办公室互操作错误 [英] microsoft office interop error

查看:91
本文介绍了微软办公室互操作错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





i我试图使用asp.net和vb.net在客户端电脑上打开一个excel文件。

i有在aspx.vb文件中指定

Hi,

i am trying to open an excel file on the clients pc using asp.net and vb.net.
i have specified

Imports Microsoft.Office.Interop

。它在测试环境中运行良好。



但是一旦我在安装了MS Office 2003的服务器(MS server 2003)上托管它,它就会抛出一个错误。当我检查时,它显示microsoft.office.interop不包含任何公共成员或无法找到



当我使用时一个try catch块它抛出以下错误

in the aspx.vb file. and it works fine in the test environment.

but once i host it on the server (MS server 2003) having MS office 2003 installed, it throws an error. and when i check, it shows "microsoft.office.interop doesnt contain any public member or cannot be found"

and when i use a try catch block it throw the below error

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



请帮我解决这个问题。



谢谢

Joe


Please help me out on this.

thanks
Joe

推荐答案

错误消息:



检索具有CLSID的组件的COM类工厂{00024500-0000-0000- C000-000000000046}由于以下错误而失败:80070005拒绝访问。 (HRESULT异常:0×80070005(E_ACCESSDENIED))。

解决方案:



这是一个COM权限问题。



开始>运行> dcomcnfg(或mmc -32,然后手动添加组件服务管理单元,如果在步骤3中找不到该应用程序)

导航到组件服务>电脑>我的电脑> DCOM配置

找到麻烦的MS应用程序(例如:Excel的Microsoft Excel应用程序或Word的Microsoft Word 97 - 2003文档)

右键单击> ;属性

在安全选项卡上:选择启动和激活权限下的自定义,然后单击编辑...

添加运行站点的帐户(例如:网络服务)并分配本地发布会本地激活权限

Voila!



错误消息:



[COMException (0x800a03ec):Microsoft Excel无法访问文件'< filename>'。有几种可能的原因:

•文件名或路径不存在。

•该文件正由另一个程序使用。

•您要保存的工作簿与当前打开的工作簿具有相同的名称。

解决方案:



这似乎是一个问题使用Excel / Word / etc通过互操作路径启动时无法访问配置文件。



打开Windows资源管理器

取决于是否如果安装了32位或64位版本的办公室,则需要执行以下一项(或两项):

32位办公室安装:导航到C:\ Windows \ System32 \ config \ systemprofile

64位Office安装:导航到C:\ Windows \ SysWOW64 \ config \systemprofile

验证文件夹Desktop是否存在(如果不存在则创建它)那里)

右键单击>属性

在安全选项卡上:使用默认权限添加运行站点的帐户(例如:网络服务)(读取和执行;列出文件夹内容;阅读)

Voila!
Error Message:

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

This is a COM permissions problem.

Start > Run > dcomcnfg (or "mmc -32″ and then add the Component Services snap-in manually if you can’t find the app under step 3)
Navigate to Component Services > Computers > My Computer > DCOM Config
Locate the MS application giving you trouble (eg: "Microsoft Excel Application" for Excel or "Microsoft Word 97 – 2003 Document" for Word)
Right click > Properties
On the security tab: Select Customize under Launch and Activation Permissions and click Edit…
Add the account under which the site is running (eg: Network Service) and assign Local Launch & Local Activation permissions
Voila!

Error Message:

[COMException (0x800a03ec): Microsoft Excel cannot access the file '<filename>'. There are several possible reasons:
• The file name or path does not exist.
• The file is being used by another program.
• The workbook you are trying to save has the same name as a currently open workbook.
Solution:

This seems to be an issue with Excel/Word/etc not having access to a profile when being started via the interop route.

Open Windows Explorer
Depending on whether you installed a 32bit or 64bit version of office you will need to do one (or both) of the following:
32bit Office installation: Navigate to C:\Windows\System32\config\systemprofile
64bit Office installation: Navigate to C:\Windows\SysWOW64\config\systemprofile
Verify the folder "Desktop" exists (create it if it's not there)
Right click > Properties
On the security tab: Add the account under which the site is running (eg: Network Service) with default permissions (Read & execute; List folder contents; Read)
Voila!






i了解如何做到这一点。我必须在服务器上的EXCEL DCOM上设置NETWORK SERVICES权限。



下一个问题是,NETWORK SERVICES在创建excel文件时锁定它创建开放,删除excel文件是不可能的。



我发现添加
Hi,

i got on how to do this. I had to set NETWORK SERVICES permission on the EXCEL DCOM in the server.

the next issue is, the NETWORK SERVICES locks the excel file the moment it is created and this creates opening, and deleting the excel file impossible.

well i found out that adding
xlapp.quit()

解决了文件被锁定的问题。



现在一切正常



谢谢

solves the problem of the file being locked.

and its all fine now

thanks anyways


这可以帮到你



http://social.msdn.microsoft.com/forums/en-US/Vsexpressvb/thread/cb36a6df-cecb-4d03-afc6-e25c376a6a9b [ ^ ]


这篇关于微软办公室互操作错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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