Link to home
Start Free TrialLog in
Avatar of DaFou
DaFou

asked on

How to include remoting configuration

Ola,

I have this client in C# that makes use of remoting. The remtoing gets configerd by an external xml file to make ti more dynamic after the program has been compiled.
But now I dont need the program to be dynamic and I want to have everything included in this 1 client.cs file so that I can easily use this code from ASP.NET aswell.

here is the client.cs:

// console app
using System;
using System.Configuration;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Activation;

class Client
{
      static void Main()
      {
            RemotingConfiguration.Configure("client.exe.config");

            ICalc c = (ICalc)
                  RemotingServices.Connect(typeof(ICalc), ConfigurationSettings.AppSettings["calcURL"]);

            Console.WriteLine("c.AppDomainName (Calc) = {0}", c.AppDomainName);
            Console.ReadLine();
      }
}

and this is the application configuartion file ( app.config ):

<!-- xml -->
<configuration>
  <appSettings>
    <add key="calcURL" value="http://localhost:999/calcsrv/calc"/>
  </appSettings>

  <system.runtime.remoting>
    <application name="client">
      <channels>
        <channel ref="http" port="0">
          <clientProviders>
            <formatter ref="binary" />
          </clientProviders>
          <serverProviders>
            <formatter ref="binary" />
          </serverProviders>
        </channel>
      </channels>
    </application>
  </system.runtime.remoting>
</configuration>
ASKER CERTIFIED SOLUTION
Avatar of eternal_21
eternal_21

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