Link to home
Start Free TrialLog in
Avatar of kalliopi
kalliopi

asked on

.NET Remoting (GetObejct vs. RemotingConfiguration.Configure)

I have a strange situation.  I have a client app, where this line works correctly:
MyRemoteObj liason = (MyRemoteObj)Activator.GetObject(typeof(MyRemoteObj), 
"tcp://localhost:2396/MyRemoteObj");

Open in new window

But after doing this:
 
 RemotingConfiguration.RegisterWellKnownServiceType(typeof(MyRemoteObj),    
"tcp:`//localhost:2396/MyRemoteObj", WellKnownObjectMode.Singleton);

Open in new window

or this:
 
  String path = String.Format("{0}.config", Application.ExecutablePath);    
RemotingConfiguration.Configure(path, false);

Open in new window

I am UNABLE to use
MyRemoteObject liason = new MyRemoteObject();

Open in new window

It simply instantiates a new local object.  What am I missing?
My App config includes this:
  <system.runtime.remoting>
    <application>
      <client>
        <wdellknown type="Testing.MyRemoteObject, Testing" url="tcp://localhost:2396/MyRemoteObj"/>
      </client>
    </application>
  </system.runtime.remoting>

Open in new window

SOLUTION
Avatar of Anuradha Goli
Anuradha Goli
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kalliopi
kalliopi

ASKER

anuradhay - Thanks for the link.  The problem here is not a lack of understanding of how .NET remoting works.  I understand the concepts.  I have done remoting successfully in the past (using the same process).

The issue I'm trying to resolve is the SPECIFIC situation of .GetObject working (which tells me that the server side is configured correctly) but the NEW keyword NOT working.  On another remoting app which works, once I call the .Configure(...) method - any well known types registered there are created as CAO objects.  For some reason, that's not happening in this app - and I don't get why.

Specifically - what might prevent my app from registering/handling well known types correctly?
CodeCruiser - thanks for the suggestion.  In answer to your question, no, I'm not explicitly registering a channel.  That being said, what I don't get is that I'm doing remoting in another app, and don't need (on the client side) anything more than I have in this original post.  I put the "WellKnown" keyword in the app.config.  Call RemotingConfiguration.Configure(...) and then when I new up that type, it does so using remoting - just as expected.  For some reason, I can't get it working in this app and I'm trying to figure out why.  
Any suggestions appreciated.
Sorry - I just answered both questions myself.  I needed to be using this:            

RemotingConfiguration.RegisterWellKnownClientType

Rather than RegisterWellKnownServiceType.  Also, it appears I just had a typo in my client app.config, since <wdellknown> is not the appropriate keyword.  Changing the RegisterWellKnownType fixed the problem with that method.  Fixing the tag fixed the problem using the RemotingConfiguration.Configure.

Thanks for the help guys!