Not able to use remote config file.

I am able to use the Activator.GetObject but not the remote config file

SampleObject adServer = (SampleObject)Activator.GetObject(typeof(SampleObject), "tcp://teamsuite:1234/SampleObject");

I created a separate config file and loading that in the global.asax file via

void Application_Start(object sender, EventArgs e)
{
//System.Runtime.Remoting.RemotingConfiguration.Configure(HttpContext.Current.Server.MapPath("Client.exe.config"), false);
}

The config file is:

< xml version="1.0" encoding="utf-8" >
<configuration>
<system.runtime.remoting>
<application name="HelloLibrary">
<client>
<wellknown type="HelloLibrary.SampleObject, HelloLibrary" Url="tcp://computername:1234/SampleObject"/>
</client>
<channels>
<channel ref="tcp"/>
</channels>
</application>
</system.runtime.remoting>
</configuration>

I do not want to use the Activator.GetObject but instead use the regular new object as well as make use of the remote config file and not hard code the variables in the code. Please help.



Answer this question

Not able to use remote config file.

  • zolivier

    Looks like the images I posted did not go through. Here is the my client config file.

    Som what you are suggesting is to use activated instead of wellknown inorder to use "new" keyword.

    < xml version="1.0" encoding="utf-8" >
    <configuration>
    <system.runtime.remoting>
    <application>
    <client>
    <wellknown type="HelloLibrary.SampleObject, HelloLibrary" url="tcp://teamsuite:1234/SampleObject"/>
    </client>
    <channels>
    <channel ref="tcp" port="1234"/>
    </channels>
    </application>
    </system.runtime.remoting>
    </configuration>


  • Al33327

    I am using the wellknown at the server side and client side. Please see below in config files for server side and client side(see the first configuration from both). Please let me know if my client configuration is correct.

    Server side

    Client side


  • DevDiver

    I also found this on the internet

    "If we instantiate remote object via Activator's static methods, it'd be unnecessary for client assembly to reference remote object's assembly. This provides further separation between the remote object and the client. If client side settings are loaded from config file instead, remote object has to be instantiated using "new" keyword. This implies client has to reference remote object's assembly."

    What do you think


  • Jordan Carroll

    So, this means instead of wellknown in my client project; I should use activate in the config file and then use the "new" keyword or "createinstance". I was under the impression that I can use new since I was able to call Activator.GetObject. Please confirm.
  • mattdawg

    GetObject is for SAO. new is CAO.

  • SurajPeace

    "new" doesn't work for SAO. The semantics of "new" are that the client is creating a new instance and that's what CAO is about.

  • Atulpatel

    You are right on the first part that my client is ASP.NET. Also, my server is a Windows service which will create the remote object.

    This is what I do from ASP.NET to call the remote object via proxy. The ASP.NET creates a proxy here.

    SampleObject adServer = (SampleObject)Activator.GetObject(typeof(SampleObject), "tcp://teamsuite:1234/SampleObject");

    The issue is that I am not able to use the "new" keyword by making use of the config file and have to rely on Activator.GetObject. Please note that I am using a wellknown object hence SAO not CAO.

    I followed exactly as was in the article:

    I created a separate config file and loading that in the global.asax file via

    void Application_Start(object sender, EventArgs e)
    {
    System.Runtime.Remoting.RemotingConfiguration.Configure(HttpContext.Current.Server.MapPath("Client.exe.config"), false);
    }
    The config file(Client.exe.config) at the client(ASP.NET) is:

    < xml version="1.0" encoding="utf-8" >
    <configuration>
    <system.runtime.remoting>
    <application name="HelloLibrary">
    <client>
    <wellknown type="HelloLibrary.SampleObject, HelloLibrary" Url="tcp://computername:1234/SampleObject"/>
    </client>
    <channels>
    <channel ref="tcp"/>
    </channels>
    </application>
    </system.runtime.remoting>
    </configuration>


  • Kamen

    I am not sure I understand your question. It looks like you are largely following http://support.microsoft.com/default.aspx/kb/323490

    it seem to me that there difference between what you're doing and what you want is that you'd like to create a client activated object for which the client config looks like this [1] and the server side like this [2]

    [1] http://msdn2.microsoft.com/en-us/library/zefz38wy(vs.71).aspx
    [2] http://msdn2.microsoft.com/en-us/library/7xcfyf33(VS.71).aspx



  • Not able to use remote config file.