Tutorial :Issue with remoting when different domains are used



Question:

I have the following project: server, client, remote object. client does something, then pass the proxy of remote object to the server. All the things work property until server and client are in different domains. Now, when I try to pass result to server I have an exception

"An unhandled exception of type 'System.Runtime.Remoting.RemotingException' occurred in mscorlib.dll

Additional information: This remoting proxy has no channel sink which means either the server has no registered server channels that are listening, or this application has no suitable client channel to talk to the server. "

some sources on Internet says that I need to create some additional channel but I don't know where and how should I do that because I have the channel registration on server and client yet.

Info:  server - domain 2  client - domain 1  remote object - domain 1  

Thank you


Solution:1

Sounds like a permissions issue to me. How are you hosting your remoting objects? How are you authenticating across domains? Here's a decent article on some of the issues you might face with auth.

From this article ...

By default, a TCP client channel authenticates itself with the user identity under which the client process is running. You can specify an alternative identity by setting the domain, username, and password properties to specify an alternative identity

Have you specified correct credentials (including domain) on your channel properties?


Solution:2

then pass the proxy of remote object to the server

Can you explain this? This doesn't sound like a good idea. Typically a proxy is used to invoke remote methods (RPC). Passing the proxy back to the server, doesn't make sense. Sure it may work in some scenarios, but it just adds unnecessary complication.

If you want to pass an object, create a separate data class and pass that as a parameter to the remote method.

Common.dll

[Serializable]  public class Data  {      int a;      int b;  }  [Serializable]  public class ResultData  {      int c;  }  public interface IServerInterface  {      ResultData DoSomething(Data data);  }  

Server.dll

public class ServerObject : MarshalByRefObject, IServerInterface  {      public ResultData DoSomething(Data data)      {          // do some work on the server          return new ResultData();      }  }  

Client.exe

class Program  {      static void Main(string[] args)      {          IServerInterface proxy = CreateProxy();          ResultData result = proxy.DoSomething(new Data());        }  }  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »