How to fix '80070005 Access is denied' when accessing remote com+ object?

0

When I try to call method of COM+ object from remote PC I get error:

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)
  • I have two computers connected via ethernet. ServerPC (Windows 10 pro x64) and ClientPC (Windows 10 home).
  • I created simple com+ application (dll library, .net framework 4.6.1) on ServerPC. I copied dll from solution folder to "C:\library\" and register it via regsvcs.
  • I copied this dll to ClientPC in the same path.
  • I export my COM object from ServerPC to ClientPC as Application proxy via Component Services.
  • I created client program that access this COM object. I added dll to references.
  • I run it on ServerPC and ClientPC. On ServerPC eveything works fine. On ClientPC i get error 0x80070005 when call c.Sum(34, 65).

  • In Component Services->My Computer->Properties->COM Security i added and gave access to local user, NETWORK SERVICE and ANONYMOUS LOGON. I added this accounts in Windows Registry for items with guid {6619A740-8154-43BE-A186-0319578E02DB} too, but it didn't help.

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;
        }
    }
}

client:

ComCalculator.Calculator c = new ComCalculator.Calculator();
var res = c.Sum(34, 65);
c#
com
com+
dcom
asked on Stack Overflow Sep 10, 2019 by Vadim

1 Answer

0

ServerPC and ClientPC are not in one domain, so I needed user with same login and password on both PCs.

answered on Stack Overflow Sep 16, 2019 by Vadim

User contributions licensed under CC BY-SA 3.0