What should you do?

You work as the Microsoft.NET developer at Domain.com. The Domain.com network consists of a single Active Directory domain named Domain.com. All servers in the domain run Windows Server 2003.
The development of applications forms part of your responsibilities at Domain.com. You are currently developing an application that monitors a network for changes. The application itself consists of a Microsoft ASP.NET Web application and a Microsoft .NET Remoting server component. Both of these exist on the same server but run in different processes. Policies and rules for monitoring the network are stored in a Microsoft SQL Server 2005 database. The server component contains a class named Monitor. This class contains a method named GetChanges that returns a DataSet instance. Changes to the network are represented by DataSet. When initiated the Monitor class will retrieve all policies and rules from the database. You need to code the host application for the remote component to register the Monitor class for .NET Remoting. However, you do not want the remote component to query the database each time the GetChanges method is called. This means that you should configure a certain code segment.

What should you do? (Choose the correct code segment.)

You work as the Microsoft.NET developer at Domain.com. The Domain.com network consists of a single Active Directory domain named Domain.com. All servers in the domain run Windows Server 2003.
The development of applications forms part of your responsibilities at Domain.com. You are currently developing an application that monitors a network for changes. The application itself consists of a Microsoft ASP.NET Web application and a Microsoft .NET Remoting server component. Both of these exist on the same server but run in different processes. Policies and rules for monitoring the network are stored in a Microsoft SQL Server 2005 database. The server component contains a class named Monitor. This class contains a method named GetChanges that returns a DataSet instance. Changes to the network are represented by DataSet. When initiated the Monitor class will retrieve all policies and rules from the database. You need to code the host application for the remote component to register the Monitor class for .NET Remoting. However, you do not want the remote component to query the database each time the GetChanges method is called. This means that you should configure a certain code segment.

What should you do? (Choose the correct code segment.)

A.
TcpClientChannel channel = new TcpClientChannel();
ChannelServices.RegisterChannel(channel, false);
RemotingConfiguration.RegisterWellKnownServiceType(Get Type(Monitor), “Monitor.rem”, WellKnownObjectMode.SingleCall);

B.
IpcServerChannel channel = new IpcServerChannel(“MonitorHost”);
ChannelServices.RegisterChannel(channel, false);
RemotingConfiguration.RegisterWellKnownService Type(Get Type(Monitor), “Monitor.rem”, WellKnownObjectMode.Singleton);

C.
IpcServerChannel channel = new IpcServerChannel(“Monitor);
ChannelServices.RegisterChannel(channel, false);
RemotingConfiguration.RegisterWellKnownServiceType(Get Type(Monitor), “Monitor.rem”, WellKnownObjectMode.SingleCall);

D.
TcpClientChannel channel = new TcpClientChannel();
ChannelServices.RegisterChannel(channel, false);
RemotingConfiguration.RegisterWellKnownServiceType(Get Type(Monitor), “Monitor.rem”, WellknownObjectMode.Singleton);

Explanation:
The IPC channel allows an application to communicate with a remote object in a different application domain running the same process or in a different process on the same computer.
You should also use the Monitor class as a singleton object by calling the RegisterWellKnownServiceType method of the RemotingConfiguration class and specifying WellKnownObjectMode.Singleton. Singleton objects has a lifespan that is determined by the .NET Remoting Lease Manager. When initiated, a Singleton object releases its memory until its lease expires. Thus the constructor will not be called with every remote method invocation. This is because the Monitor class queries the database in the constructor and the Singleton method ensures that the class does not query the database with every call to GetChanges.
Incorrect answers:
A: Though you can, you should not register a TcpClientChannel instance. IPC is preferred when using the same computer for intercommunication. If using TCP, you must register a TcpServerChannel instance. And then you would need to register a TcpClientChannel instance in the client application.
C: The Monitor class should not be registered as a single-call object. These objects have a lifetime of a single method call and thus their constructors are called with every method that is invoked, which in turn would cause each invocation to GetChanges to query the database.
D: IPC is preferred over TCP in this case and you should rather be making use of the singleton object.



Leave a Reply 0

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