如何将 COM 对象 Microsoft.Office.Interop 部署到 IIS,以便我的 C# WCF 服务引用能够正常工作?

How to deploy COM object Microsoft.Office.Interop to IIS so that my C# WCF service reference will work?(如何将 COM 对象 Microsoft.Office.Interop 部署到 IIS,以便我的 C# WCF 服务引用能够正常工作?)
本文介绍了如何将 COM 对象 Microsoft.Office.Interop 部署到 IIS,以便我的 C# WCF 服务引用能够正常工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在本地计算机上从 IIS 7 运行我的 Web 应用程序时遇到错误,与 Microsoft.Office.Interop.Outlook 相关,如下所示...

I am getting an error when trying to run my web application from IIS 7 on my local machine regarding Microsoft.Office.Interop.Outlook that is like the following...

由于以下错误,检索具有 CLSID {0006F03A-0000-0000-C000-000000000046} 的组件的 COM 类工厂失败:80070005 访问被拒绝.(来自 HRESULT 的异常:0x80070005 (E_ACCESSDENIED)).

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

当我从 VS2010 和 Cassini 运行相同的网络应用程序时,我没有问题.

When I run this same web app from VS2010 and Cassini I have no problem.

当我从 IIS 7 运行 Web 应用程序时,我将 VS2010 指向 IIS 虚拟目录.事实上,我什至让 VS2010 创建了虚拟目录.所以我可以从 VS2010 调试并收集我在这里发布的错误.

When I run the web app from IIS 7 I point my VS2010 at the IIS Virtual Directory. In fact I even had VS2010 create the Virtual Directory. So I am able to debug from VS2010 and gather the error I posted here.

我访问了 Microsoft.Office.Interop.Outlook.dll 文件并让每个人都可以读取、写入、修改和删除.只是为了排除安全问题.

I have gone to the Microsoft.Office.Interop.Outlook.dll file and given EVERYONE read,write,modify, and delete. Just to rule out security.

在引用 Microsoft.Office.Interop dll 时还有其他步骤吗?我是否应该对此进行不同的配置.再次切换回在 Cassini 中运行,没有问题.

Are there other steps when referencing Microsoft.Office.Interop dlls? Should I configure something regarding this differently. Again switch back to running in Cassini and no problems.

推荐答案

在我的服务器上,SharePoint 已安装并在帐户网络服务"下运行.那将是一个隐藏帐户,通常不允许运行 COM 对象.如果您进入 IIS 并查看它正在使用哪个应用程序池(在高级设置下).然后检查该池的标识.一位朋友建议我们在指定帐户(如 [domain]svcSharepoint)下运行我们的 SharePoint 应用程序池(和其他服务),以便您可以明确授予权限.否则,网络服务帐户将显示为 [domain][machine name]$(注意末尾的 $,表示隐藏帐户").

On my server SharePoint is installed and running under the account "Network Service". That would be a hidden account, that normally would not be allowed to run COM objects. If you go into IIS and see which App Pool it is using (under Advanced Settings). Then check the Identity of that pool. A friend had recommended that we run our SharePoint app pool (and other services) under a named account (like [domain]svcSharepoint) so you can explicitly give permission. Otherwise, the Network Service account would show up as [domain][machine name]$ (note the $ at the end, meaning "hidden account").

另一个因素是如果您将它安装在 Server 2008 R2 上,因为 UAC 的东西要强大得多,并且肯定会拒绝这种交互.关闭 UAC 有点冒险,但可能是赢家.

One other factor would be if you installed this on Server 2008 R2, because the UAC stuff is much stronger and would deny this kind of interaction for sure. Turning off the UAC is a little risky, but could be a winner.

最后一个因素是检查该 COM 对象的 DCOM 配置.[开始菜单,管理员工具][组件服务][DCOM 配置].按名称或 GUID、属性、安全性查找 Outlook.

Last factor would be checking the DCOM configs for that COM object. [Start Menu, Administrator Tools][Component Services][DCOM Config]. Find Outlook by name or by GUID, Properites, Security.

这篇关于如何将 COM 对象 Microsoft.Office.Interop 部署到 IIS,以便我的 C# WCF 服务引用能够正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)