Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8487445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:14:33+00:00 2026-06-10T21:14:33+00:00

I have a server\client application which needs to request two different remote proxies via

  • 0

I have a server\client application which needs to request two different remote proxies via an Activator.

I ran into a situation where if you request a remote object through Activator.GetObject without creating a channel and then later on create a channel and try to get a seperate object, then the second object will fail. Let me show a sample application to demonstrate the issue:

Here are the two remote objects:

namespace HelloRemoteObject
{
    public class FirstObject : MarshalByRefObject
    {
        public String FirstObjectMethod()
        {
            return "FirstObjectMethod";
        }
    }

    public class SecondaryObject : MarshalByRefObject
    {
        public String SecondObjectMethod()
        {
            return "Secondary object method return string";
        }
    }
}

Here is the server, which just registers an http server channel on a specific port and then waits:

public static int Main(string[] args)
{
    // register the channel
    IDictionary properties = new Hashtable
                                    {
                                        {"timeout", 1000},
                                        {"port", 9099}
                                    };

    var serverChannel = new HttpServerChannel(properties, new BinaryServerFormatterSinkProvider());
    ChannelServices.RegisterChannel(serverChannel, false);

    // register two known types
    RemotingConfiguration.RegisterWellKnownServiceType(typeof(FirstObject), "FirstObjectUri", WellKnownObjectMode.Singleton);
    RemotingConfiguration.RegisterWellKnownServiceType(typeof(SecondaryObject), "SecondaryObjectUri", WellKnownObjectMode.Singleton);

    Console.WriteLine("Hit <enter> to exit...");
    Console.ReadLine();
    return 0;
}

And here is the client. If you pass in any argument then it will register a named channel first. Then it will get the two remote proxies and call a single method on them. If you don’t give it any arguments it will first get the proxy to the first object, then create a channel for the second proxy, and then try and act on the two.

static void Main(string[] args)
{
    var registerChannelFirst = args.Length > 0;
    if(registerChannelFirst)
    {
        Console.WriteLine("Registering channel first");

        RegisterHttpChannel();
    }
    else
    {
        Console.WriteLine("Letting Activator.GetObject register an http client channel by default");
    }

    var firstRemoteObject = (FirstObject)Activator.GetObject(typeof(FirstObject), "http://127.0.0.1:9099/FirstObjectUri");

    if(!registerChannelFirst)
    {
        RegisterHttpChannel();
    }

    var secondRemoteObject = (SecondaryObject)Activator.GetObject(typeof(SecondaryObject), "http://127.0.0.1:9099/SecondaryObjectUri", );

    Console.WriteLine(firstRemoteObject.FirstObjectMethod());
    Console.WriteLine(secondRemoteObject.SecondObjectMethod());
}

private static void RegisterHttpChannel()
{
    // register the channel
    IDictionary properties = new Hashtable
                                    {
                                        {"name" , "ChannelName"}
                                    };
    var clientChannel = new HttpClientChannel(properties, new BinaryClientFormatterSinkProvider());

    ChannelServices.RegisterChannel(clientChannel, false);
}

If you register a channel first, before activating then everything works fine.

Letting the activator go first and then getting a second object and you get an exception.

If you don’t try and activate two objects and just let the activator get an object then that also works. I’m curious to know why this is?

I’m curious because lets say I don’t care about channel properties then I can just as easily create a single channel and be done with it, however, if one object needs to utilize a timeout on the channel, but the other object does not, then I need to create two separate channels. Is there then a way to bind an object to a channel?

I’m also aware that remoting has gone the way of wcf, but thats not an option for me right now.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T21:14:34+00:00Added an answer on June 10, 2026 at 9:14 pm

    So I think the solution here is just to always register a channel name. When I register a channel name the output looks like this (ChannelName is the output of ChannelServices.RegisteredChannels‘s names)

    Registering channel first
    ChannelName
    FirstObjectMethod
    Secondary object method return string
    

    If I register the channel after the activator has run, it looks to have created its own internal default channel

    Letting Activator.GetObject register an http client channel by default
    http client, ChannelName
    
    Unhandled Exception: System.Runtime.Remoting.RemotingException: System.ArgumentNullException: No message was deserialized prior to calling the DispatchChannelSink.
    Parameter name: requestMsg
    at System.Runtime.Remoting.Channels.DispatchChannelSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)
    at System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)
    at System.Runtime.Remoting.Channels.Http.HttpServerTransportSink.ServiceRequest(Object state)
    at System.Runtime.Remoting.Channels.SocketHandler.ProcessRequestNow()
    
    
    Server stack trace:
    
    
    Exception rethrown at [0]:
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at HelloRemoteObject.FirstObject.FirstObjectMethod()
       at HelloClient.HelloClient.Main(String[] args) in 
    

    So something is getting confused with having two registered http channels. I would’ve stepped through the .net source but I was having issues.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a client application which is sending a request to a server. Server
I have a client server application in which I need to transmit a user
I have a client server application in which the server and the client need
We have a Server/Client cybercafe management application which used to work fine on Windows
I have a client-server Silverlight application, which is use Socets. I have server appliaction
I am developing an application in C# WPF which will have Client-Server architecture (Client
I have an application that needs to make a SOAP client request to a
i have a client-server application which uses .NET Remoting communication. For authentication reasons i
I have a server-client application [TCP sockets, .NET 4.0].. the application about : do
I have client/server application where the client app will open files. Those files get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.