【问题标题】:How to fix '80070005 Access is denied' when accessing remote com+ object?访问远程 com+ 对象时如何修复“80070005 访问被拒绝”?
【发布时间】:2019-09-10 09:20:17
【问题描述】:

当我尝试从远程 PC 调用 COM+ 对象的方法时出现错误:

System.InvalidCastException
  HResult=0x80004002
  Message=Unable to cast COM object of type 'System.__ComObject' to interface type 'System.EnterpriseServices.IRemoteDispatch'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{6619A740-8154-43BE-A186-0319578E02DB}' failed due to the following error: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).
  Source=System.EnterpriseServices
  StackTrace:
   at System.EnterpriseServices.RemoteServicedComponentProxy.Invoke(IMessage reqMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at ComCalculator.Calculator.Sum(Int32 a, Int32 b)
   at ConsoleApp1.Program.Main(String[] args)
  • 我有两台计算机通过以太网连接。 ServerPC(Windows 10 pro x64)和 ClientPC(Windows 10 家庭版)。
  • 我在 ServerPC 上创建了简单的 com+ 应用程序(dll 库,.net 框架 4.6.1)。我将 dll 从解决方案文件夹复制到“C:\library\”并通过 regsvcs 注册。
  • 我将此 dll 复制到 ClientPC 的同一路径中。
  • 我通过组件服务将我的 COM 对象从 ServerPC 导出到 ClientPC 作为应用程序代理。
  • 我创建了访问此 COM 对象的客户端程序。我在引用中添加了 dll。
  • 我在 ServerPC 和 ClientPC 上运行它。在 ServerPC 上一切正常。在 ClientPC 上调用 c.Sum(34, 65) 时出现错误 0x80070005。

  • 在“组件服务”->“我的电脑”->“属性”->“COM 安全”中,我添加并授予本地用户、网络服务和匿名登录的访问权限。我也在 Windows 注册表中为 guid 为 {6619A740-8154-43BE-A186-0319578E02DB} 的项目添加了此帐户,但没有帮助。

dll:

[assembly: ApplicationActivation(ActivationOption.Server)]
[assembly: ApplicationAccessControl(false)]

namespace ComCalculator
{
    [ClassInterface(ClassInterfaceType.AutoDual)]
    [ComponentAccessControl(false)]
    public class Calculator : ServicedComponent
    {
        [AutoComplete(true)]
        public int Sum(int a, int b)
        {
            return a + b;
        }
    }
}

客户:

ComCalculator.Calculator c = new ComCalculator.Calculator();
var res = c.Sum(34, 65);

【问题讨论】:

    标签: c# com com+ dcom


    【解决方案1】:

    ServerPC 和 ClientPC 不在一个域中,所以我需要在两台 PC 上使用相同登录名和密码的用户。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-02-28
      • 1970-01-01
      • 2012-02-21
      • 2017-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多