What should you do to ensure that the client Console Application calls the Add method on SERVER1?

An assembly named SimpleMathLib is deployed to the Bin folder that is under a virtual directory named SimpleMathHost, which is on an IIS server named SERVER1.
The SimpleMathLib assembly contains the following code.

namespace SimpleMath
{
public class SimpleMathClass : MarshalByRefObject
{
public double Add(double x, double y)
{
return x + y;
}
}
}

The Web.config file under the SimpleMathHost virtual directory contains the proper configuration to host SimpleMath as a remoting object.
You write a client Console Application and add a reference to the SimpleMathLib assembly.
You need to ensure that the client Console Application calls the Add method on SERVER1 and returns the correct sum of the parameters to the Console Application.

What should you do?

An assembly named SimpleMathLib is deployed to the Bin folder that is under a virtual directory named SimpleMathHost, which is on an IIS server named SERVER1.

The SimpleMathLib assembly contains the following code.

namespace SimpleMath
{
public class SimpleMathClass : MarshalByRefObject
{
public double Add(double x, double y)
{
return x + y;
}
}
}

The Web.config file under the SimpleMathHost virtual directory contains the proper configuration to host SimpleMath as a remoting object.

You write a client Console Application and add a reference to the SimpleMathLib assembly.

You need to ensure that the client Console Application calls the Add method on SERVER1 and returns the correct sum of the parameters to the Console Application.

What should you do?

A.
Write the following code in the client application.
TcpChannel chan = new TcpChannel();
ChannelServices.RegisterChannel(chan, false);
SimpleMath.SimpleMathClass sm = new SimpleMathClass();
Console.WriteLine(sm.Add(2, 2).ToString());

B.
Write the following code in the client application.
SimpleMathClass sm = (SimpleMathClass) Activator.GetObject(typeof(SimpleMathClass), “http://server1:80/SimpleMathHost/SimpleMath.rem”);
Console.WriteLine(sm.Add(2, 2).ToString());

C.
Write the following code in the client application.SimpleMath.S
impleMathClass sm = (SimpleMathClass) Activator.GetObject(typeof(SimpleMathClass), “tcp://server1:80/SimpleMathHost/SimpleMath.rem”);
Console.WriteLine(sm.Add(2, 2).ToString());

D.
Write the following code in the client application.
SimpleMath.SimpleMathClass sm = (SimpleMathClass) Activator.CreateInstance(typeof(SimpleMathClass), new string[] {“http://server1:80/SimpleMathHost/SimpleMath.rem”, “SimpleMath.SimpleMathClass, SimpleMathLib”});
Console.WriteLine(sm.Add(2, 2).ToString());



Leave a Reply 0

Your email address will not be published. Required fields are marked *