C# 允许在Web窗体项目中访问Outlook互操作

C# 允许在Web窗体项目中访问Outlook互操作,c#,asp.net,iis,permissions,interop,C#,Asp.net,Iis,Permissions,Interop,我在使用web窗体项目时遇到IIS权限和Microsoft Outlook 2010互操作程序集问题 我创建了一个概念验证项目,以确保我可以在我负责的特定情况下使用Microsoft的Outlook interop程序集。演示项目非常有效,我没有遇到任何问题。现在我正试图将它集成到我们的主项目中,我遇到了一个IIS权限问题。我的网站在本地IIS 7中运行。在IIS管理器中,我单击应用程序池->我的网站->高级设置。在这个窗口中,我有一个名为“fileshare”的自定义标识,带有密码(“file

我在使用web窗体项目时遇到IIS权限和Microsoft Outlook 2010互操作程序集问题

我创建了一个概念验证项目,以确保我可以在我负责的特定情况下使用Microsoft的Outlook interop程序集。演示项目非常有效,我没有遇到任何问题。现在我正试图将它集成到我们的主项目中,我遇到了一个IIS权限问题。我的网站在本地IIS 7中运行。在IIS管理器中,我单击应用程序池->我的网站->高级设置。在这个窗口中,我有一个名为“fileshare”的自定义标识,带有密码(“fileshare”是为了在开发网络服务器上安全访问网站的图像、pdf文件等而创建的)。我将outlook interop程序集复制到我们的公共共享程序集文件夹中,而不是从GAC引用它。我为程序集授予了IUSER、网络服务、IIS_WPG、ASP.NET和文件共享的所有权限。我得到以下运行时错误:

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)). 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 {0006F03A-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 <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.

在做了更多的研究之后,我决定使用互操作程序集是一个错误的选择。正如Alexi所说,它不是通过网络使用的。

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

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

您不应该。。。不支持Outlook在服务器环境中运行-详细信息请参见此处。
<system.web>  
    <authentication mode="Windows"/> 
    <identity impersonate="true"/>
</system.web>