Top 50+ .Net Interview Questions and Answers - 1

Question: 1

What is the difference between the Singleton mode and SingleCall mode?

Using the Singleton mode, one object can serve the requests of all clients. An instance of the Singleton object is created when the first client tries to access it. After that, the subsequent client calls are channeled to the same Singleton object.

The Singleton Object maintains the state across requests or method calls. This state is globally shared between all the clients.

The SingleCall mode instantiates an object to serve a single client request. When you configure an object as SingleCall, the .NET Remoting Framework activates a new instance of that type for every method invocation a client makes, after which it is garbage collected for recycling. Since the SingleCall mode handles only one request, it does not store state between requests and is called stateless. The SingleCall mode potentially allows for greater server scalability.

Question: 2

What is the difference between remotable and nonremotable objects?

Remotable objects are those that can be accessed outside their own AppDomain using a proxy.

On the other hand, nonremotable objects are those that cannot be accessed outside their own AppDomain, which means instances of a nonremotable object cannot cross .NET remoting boundaries.

However, if you attempt to pass an instance of a non remotable object to anothe AppDomain, an exception will occur.

The nonremotable objects are designed for use within the same AppDomain in which they were created and are always accessed directly from the AppDomain.

In addition, the nonremotable objects cannot be copied be copied or represented in another Appdomain.

Question: 3

What are message sinks?

Message sinks are the objects that are used to transfer a message from a client application to a server side object. A sink usually receives a message from another object, processes that message, and passes it on to the next sink in the chain.

Sink provides secuirty by encrypting the data or messages before sending it.

All message sinks implement the IMessageSink interface which has a single property, NextSink, and two methods, synProcessMessage () and AsyncProcessMessage ().

Question: 4

What are different types of message sinks?

Message sinks can be categorized as follows:

Envoy Sink - Enables a server to pass message to a client. It is mainly created from the server context and used to collect client information and pass it to the server.

Server Context Sink - Receives the messages from server side.

Server Object Sink - It is created for a particular object if its class defines context sinks and attributes.

Client Context Sink - It is created by any object that is within the context on objects located outside the context.

Question: 5

Describe client actived objects (CAOS)?

The client activated objects (CAOs) are objects whose lifetime is directly controlled by the client.

To handle well known CAOs, .NET Remoting Framework assigns a Uniform Resource IDentifier (URI) to each instance of a CAO object.

The CAO objects are created on the server corresponding to the client requests.

A CAO instance serves only the client that creates it and does not get discarded with each request.

It also enables the CAO to maintain state for each client that it is serving; however, it cannot share the common state. The CAOs are mostly used when the client needs to maintain a private session with the remote object.

Related Questions