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 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);
ServerPC and ClientPC are not in one domain, so I needed user with same login and password on both PCs.
User contributions licensed under CC BY-SA 3.0