C# DCOM event binding Unathorized Execption

266 views Asked by At

For a project I am working on I have to interface with a third-party DCOM library. I started with COM interop and this worked just fine locally, then I switched to DCOM and now I keep getting an unauthorized access exception (0x80070005) when trying to bind an event handler to the exposed event. Below is a summary of what I do in code:

    public void connect(string server)
    {
            object dcomObj = null;
            var guidB = Guid.Parse("c8c1f57f-0d7c-40b3-b17c-2eac12512006");
            var typ = Type.GetTypeFromCLSID(guidB, server, true);
            object[] url = { new UrlAttribute(server) };

            dcomObj = Activator.CreateInstance(typ, null, url);
            user = (RemoteObjectInterface)dcomObj ;

            user.getState(); //works fine locally and remotely
            user.stateChange += this.User_StateChange; //only works locally
    }

I tried setting every permission I could find on the web but I without success. Does anyone have an Idea as to why only the binding of events fails?

RemoteObjectInterface inherits from both the IRemoteObjectEvents and the IRemoteObject. These interface come from the interop ms generated for me when I imported the original dll.

The server is a windows server 2003 VM in virtual box with a bridged network adapter. On the server Everyone is admin (including guest) and limits are set to full access and defaults are set to full access. I am building and running my code on c# .net 4.5.2 from a Windows 10 machine using visual studio 2015.

The sample application that comes with the SDK also fails when I try to use it remotely, the server registers the user but the sample application never realizes that it logged in successfully, I suspect that this behaviour is related to the failing of event binding.

TL;DR I can get and use a remote object but when I try to add an event handler I get an unauthorized exception (0x80070005), why does this happen on event binding? And how do I fix it?

1

There are 1 answers

3
Bart Pues On

I had the same problem. For me the issue was I had a AD running on the same device and had to disable the loopback check in the registry. Other solution could be better I assume, but for me the registry hack will do.