Interview Tips Interview Tips, Interview Questions and Answers

19May/100

What is the difference between Web Services and Remoting?

Both Remoting and Web Services are ways of communication between applications.

Remoting - In remoting, the applications involved in the communication process may be located on the same computer, different computers in a same or different network. In remoting, both applications know about each other. A proxy of an application object is created on the other application.

Web Services - Communication between applications using web services is platform independent and programming independent. The application that consumes the web service, simply accesses it, without needing to know how this web service has actually been implemented & created.

Here are some of the major differences:
* ASP.NET Web Services may be accessed using HTTP only. Remoting objects may be accessed over any protocol like TCP, SMTP, HTTP
* Web Service are Stateless, whereas Remoting has support for both stateless and with-state environment, which is achieved using Singleton and Singlecall activation
* ASP.NET provides good support to create Web Services. They are easy to deploy. In comparison, Remoting is little complex.
* Web services may be considered very reliable, due to the fact that they are hosted on IIS. In remoting, if IIS is'nt used, then methods like plumbing have to be used to ensure the application reliability.
* In .NET, when we create an application that consumes a web service, the web service may or may not be built using .NET. But while implementing Remoting in .NET, both the applications must be built in .NET.
* Using web services, only a limited number of types may be serialized (XML). Using Remoting, objects like SOAP objects, Binary objects & XML Objects may be serialized.

18May/100

Questions on XSLT and xPath in .NET

Define XSLT.

XSLT language is used for transforming XML documents into XHTML documents. It also transforms XML into another XML document.

What is XPATH?

XPath is a language that is used to navigate through XML documents.It can find information in an XML document like elements and attributes.

Define XMLReader Class.

The XMLReader Class (Assembly: System.Xml.dll) represents a reader that provides fast, non-cached, forward-only access to XML data.

Define XMLValidatingReader class.

The XMLValidatingReader class (Assembly: System.Xml.dll) represents a reader that provides:

- Document type definition (DTD),
- XML-Data Reduced (XDR) schema, and
- XML Schema definition language (XSD) validation

17May/100

Explain what a permission is in .NET

Permissioning is tha ability the CLR possesses to allow or deny a certain program to access a resource. The .net set of permissions is included in the System.Security.Permissions namespace. A user can create his own permission set and should include it in .NET security system.

The list of in-built permission sets is as follows:

- Nothing permission set
- Execution permission set
- Internet permission set
- LocalIntranet permission set
- Everything permission set
- SkipVerification permission set
- FullTrust permission set

16May/100

.NET Object Serialization – How can I optimize the serialization process?

How can I optimize the serialization process?

The first call to a Web Service takes long because XmlSerializer generate an assembly optimized for each type in memory.

To optimize the serialization process pregeneration of serialization assembly with Visual Studio or sgen.exe is needed.

Implementing serialization separately can also increase the performance.

What is Formatters? Explain the binary formatter and the SOAP formatter.

A formatter determines the serialization format for objects.

.NET framework provides Binary formatter and SOAP formatter which inherit from the IFormatter interface

The Binary Formatter

It provides binary encoding for compact serialization for storage or socket-based network streams.
It is not appropriate for data to be passed through a firewall.

The SOAP Formatter

It provides formatting that can be used to enable objects to be serialized using the SOAP protocol.
The class is used for serialization through firewalls or diverse systems.

15May/100

.NET Object Serialization – Difference between the SoapFormatter and the XmlSerializer

What is the difference between the SoapFormatter and the XmlSerializer?

SoapFormatter

SOAP formatter will actually take the field values of an object and store all of that information in the stream passed.

SoapFormatter is better to serialize arbitrary data

XmlSerializer

XML Serialization would just serialize the public properties of an object.

The XML Serializer is used typically for serializing simple types across web services

xmlserializer is better, more flexible and faster

14May/100

.NET Object Serialization – How do you encapsulate the binary serialization?

How do you encapsulate the binary serialization?

public static void SerializeBinary( object o, string file_name)
{
using (FileStream fs = new FileStream(file_name, FileMode.Create)) {
BinaryFormatter fmt = new BinaryFormatter ();
fmt.Serialize(fs, o);
}
}

How do you implement a custom serialization?

CUSTOM SERIALIZATION implementation
public class A: ISerializable
{
private int a;
protected A(SerializationInfo si, StreamingContext sc)
{
this.a = serializationInfo.GetInt32("a");
}
public void ISerializable.GetObjectData(SerializationInfo si, StreamingContext sc)
{
si.AddValue("a", this.a);
}
}

13May/100

What are the main advantages of binary serialization?

An object is stored in a file, a database or even in the memory. However, data to be transferred over a network needs to be in a linear form for which serialization and deserialization are used.

Advantage of serialization is the ability of an object to be serialized into a persistent or a non-persistent storage media and then reconstructing the same object later by de-serializing the object.

Also Binary Serialization is faster, supports complex objects too with read only properties and even circular references.

11May/100

Explain about Serialization in .NET. Explain binary serialization and XML serialization

Explain about Serialization in .NET. Explain binary serialization and XML serialization

System.Runtime.Serialization namespace provides Serialization in .NET.
The IFormatter interface in the namespace contains Serialize and De-serialize methods that save and load data of a stream.
So we need stream as a container for the serialized object(s) and a formatter that serializes these objects onto the stream to implement serialization in .net.

Binary serialization is a mechanism that creates exact binary copy of the object onto the storage media by writing the data to the output stream such that it can be used to re-construct the object automatically.

XML serialization results in strongly typed classes with public properties and fields that are converted to a serial format for storage or transport. This XML stream conforms to a specific XML Schema definition language (XSD) document.

Explain why Serialization.

An object is stored in a file, a database or even in the memory. However, data to be transferred over a network needs to be in a linear form for which serialization and deserialization are used.

Advantage of serialization is the ability of an object to be serialized into a persistent or a non-persistent storage media and then reconstructing the same object later by de-serializing the object.

Remoting and Web Services depend heavily on Serialization and De-serialization.

Explain the components that comprise the binary serialization architecture.

To binary serialize an object we need a FileStream object,
Constructor: FileStream(file_name, FileMode.Create);

And

BinaryFormatter
Constructor: binaryFormatter.Serialize(fileStreamObject, object1);