FAQ'S ON .NET BASICS PART THREE

What are XML Doc comments (comments start with three slashes ///)?

The XML Doc comments are special kind of comments that can be recognized by Document utility to automatically generate the documentation of your methods, types and regions.

Using COM components in .NET and How to add a reference to a COM component?

The .NET does not encourage the use of COM component directly inside the managed application! Although, the .NET framework contains utilities that enable COM components to be used inside the .Net applications seamlessly.

How it is done?

The .NET utilities like TlbImp generates the wrapper .NET assembly for the COM component which provides the same calling interface to the client as exposed by the COM component. Inside the wrapper methods, it calls the actual methods of the COM component and returns the result back to the caller. The generated wrapper .NET assembly is called the ‘Runtime Callable Wrapper’ or RCW.

To use a COM component in your Visual Studio.NET project, you need to add a reference of the COM component in the Reference node of the project node of the solution inside the solution explorer window. The great thing about Visual Studio.Net is that it allows you to add a reference to the COM component in exactly the similar way as you add the reference to the .NET assembly. The Visual Studio.NET automatically creates the runtime callable wrapper assembly for the referenced COM component.

To add a reference to a COM component, right click the ‘Reference’ node under the project node inside the solution explorer and select the ‘Add Reference…’ option. It will show you a user interface screen where you browse for the target COM component. When you have selected the component, press the ‘Select’ button and then press OK. This will add a new reference node in the Reference sub tree of the project. By selecting the added reference node, you can edit its properties from the properties window.

Note: The process of importing a COM component into .NET is called ‘COM interoperability with .NET’

What is .NET Framework and what are CLR, CTS and CLS?

. NET is a software platform. It's a language-neutral environment for developing .NET applications that can easily and securely operate within it.

The .NET Framework has two main components: the Common Language Runtime (CLR) and the .NET Framework class library.

The Runtime can be considered an agent that manages code at execution time. Thus providing core services such as memory management, thread management, and remoting. Also incorporating strict type safety, security and robustness.

The class library is a comprehensive collection of reusable types that you can use to develop traditional command-line, WinForm (graphical user interface) applications, Web Forms and XML Web services.

The .NET Framework provides a Runtime environment called the Common Language Runtime or (CLR) that handles the execution of the code and provides useful services for the implementation of the application. CLR takes care of code management upon program execution and provides various services such as memory management, thread management, security management and other system services.

The managed code targets CLR benefits by using useful features such as cross-language integration, cross-language exception handling, versioning, enhanced security, deployment support, and debugging.

Common Type System (CTS) describes how types are declared, used and managed. CTS facilitates cross-language integration, type safety, and high performance code execution. The CLS is a specification that defines the rules to support language integration. This is done in such a way, that programs written in any language (.NET compliant) can interoperate with one another. This also can take full advantage of inheritance, polymorphism, exceptions, and other features.

What is MSIL / IL? What is JIT (Just In Time)?

When compiling the source code to managed code, the compiler translates the source into Microsoft intermediate language (MSIL). This is a CPU-independent set of instructions that can efficiently be converted to native code. Microsoft intermediate language (MSIL) is a translation used as the output of a number of compilers. It is the input to a just-in-time (JIT) compiler. The Common Language Runtime includes a JIT compiler for the conversion of MSIL to native code.

Before Microsoft Intermediate Language (MSIL) can be executed it, must be converted by the .NET Framework just-in-time (JIT) compiler to native code. This is CPU-specific code that runs on the same computer architecture as the JIT compiler. Rather than using time and memory to convert all of the MSIL in a portable executable (PE) file to native code. It converts the MSIL as needed whilst executing, then caches the resulting native code so its accessible for any subsequent calls.

What is Code Access Security (CAS)? How does CAS work? Who defines the CAS code groups?

Code Access Security (CAS) is part of the .NET security model. CAS determines whether or not a piece of code is allowed to run and also what resources to use. For example, CAS will prevent malicious code from entering your system and causing havoc.

The CAS security policy revolves around two key concepts - code groups and permissions. Each .NET assembly is a member of a particular code group and each code group is granted the permissions specified in a named permission set. An example: Using the default security policy, a control downloaded from a web site belongs to the 'Zone - Internet' code group which complies to the permissions defined by the 'Internet' named permission set.

Microsoft defines some default policies but you can modify these and even create your own. To view the code groups defined on your system; Run 'caspol' from the command-line and checkout the different options on display.

What is serialization in .NET and what are the ways to control serialization?

Serialization is the process of converting an object into a stream of bytes. On the other hand Deserialization is the process of creating an object from a stream of bytes. Serialization/Deserialization is used to transport or to persist objects.

Serialization can be defined as the process of storing the state of an object to a storage medium. During this process, the public and private fields of the object and the name of the class, including the assembly are converted to a stream of bytes. Which is then written to a data stream. Upon the object's subsequent deserialized, an exact clone of the original object is created.

Binary serialization preserves Type fidelity, which is useful for preserving the state of an object between different invocations of an application. For example: An object can be shared between different applications by serializing it to the clipboard.

You can serialize an object to a stream, disk, memory, over a network, and so forth. Remoting uses serialization to pass objects "By Value" from one computer or application domain to another. XML serialization serializes only public properties and fields and does not preserve Type fidelity.

This is useful when you want to provide or consume data without restricting the application that uses the data.

As XML is an open standard, it is an attractive choice for sharing data across the Web. SOAP is also an open standard, which makes it an attractive choice too. There are two separate mechanisms provided by the .NET class library - XmlSerializer and SoapFormatter/BinaryFormatter. Microsoft uses XmlSerializer for Web Services, and uses SoapFormatter/BinaryFormatter for remoting. Both are available for use in your own code.

What is Active Directory? What namespace should I use to use Active Directories?

Active Directory Service Interfaces (ADSI) is a programmatic interface for the Microsoft Windows Active Directory. It enables your applications to interact with different directories on a network using a single interface.

Visual Studio .NET and the .NET Framework make it easy to add ADSI functionality with the DirectoryEntry and DirectorySearcher components. Using ADSI you can create applications that perform common administrative tasks, such as backing up databases, accessing printers and managing user accounts.

ADSI allows:

1) Log on once to work with diverse directories. The DirectoryEntry component class provides username and password properties that can be entered at Runtime and are passed to the Active Directory object you are bound to.

2) Use of an Application-Programming Interface (API) to perform tasks on multiple directory systems. This includes multi protocol support. The DirectoryServices namespace provides the classes to perform most administrative functions such as creating users.

3) Perform "Rich Querying" on directory systems. ADSI technology supports searching for objects with two query dialects: SQL and LDAP.

4) Access and use a single or hierarchical tree structure for administering and maintaining a diverse and complicated network.

5) Integrate directory information with databases such as ?SQL Server. The DirectoryEntry path may be used as an ADO.NET connection string.

Name space to be imported when working with Active Directories:

System.DirectoryServices

Can I use the Win32 API from a .NET Framework program?

Using platform invoke it's possible. .NET Framework programs can access native code libraries by means of static DLL entry points.

RELATED POSTS

ASP.NET INTERVIEW QUESTIONS AND ANSWERS PART ONE

ASP.NET INTERVIEW QUESTIONS AND ANSWERS PART TWO

ASP.NET INTERVIEW QUESTIONS AND ANSWERS PART THREE

ASP.NET INTERVIEW QUESTIONS AND ANSWERS PART FOUR

ASP.NET INTERVIEW QUESTIONS AND ANSWERS PART FIVE

ADO.NET INTERVIEW QUESTIONS AND ANSWERS PART ONE

ADO.NET INTERVIEW QUESTIONS AND ANSWERS PART TWO

You can also learn the concept of frame work concept in detail with questions and answers in the following place.

MICROSOFT DOT NET FRAME WORK QUESTIONS AND ANSWERS PART ONE

MICROSOFT DOT NET FRAME WORK QUESTIONS AND ANSWERS PART TWO

MICROSOFT DOT NET FRAME WORK QUESTIONS AND ANSWERS PART THREE

MICROSOFT DOT NET FRAME WORK QUESTIONS AND ANSWERS PART FOUR

MICROSOFT DOT NET FRAME WORK QUESTIONS AND ANSWERS PART FIVE

MICROSOFT DOT NET FRAME WORK QUESTIONS AND ANSWERS PART SIX

MICROSOFT DOT NET FRAME WORK QUESTIONS AND ANSWERS PART SEVEN

MICROSOFT DOT NET FRAME WORK QUESTIONS AND ANSWERS PART EIGHT

MICROSOFT DOT NET FRAME WORK QUESTIONS AND ANSWERS PART NINE

MICROSOFT DOT NET FRAME WORK QUESTIONS AND ANSWERS PART TEN

No comments:

Post a Comment