Friday, March 27, 2009

.Net Framework Questions (Set 2)



Note: Please naviagate to the other set of questions by clicking the links in the "Other Questions" section on the right hand side
What is CODE Access security?
.Net Framework provides sceurity at the code level also which is known as code access security (CAS). CAS is part of .NET security model that determines whether or not a piece of code is allowed to run and what resources it can use while running. Example CAS will allow an application to read but not to write and delete a file or a resource from a folder. CAS settings can be done using Caspol.exe tool.
What is a satellite assembly?
When we use the same application for different languages we use resources files (.resx files) to show the same application in different languages. These resources when formed as an assembly are called as satellite assembly.

How to prevent my .NET DLL to be decompiled?
When we compile any .net code it gets compiled in to MSIL. This MSIL code can easily be reverse engineered by using ILDASM tool. However we can prevent the .net dlls to be decompiled by using "obfuscation". For obfuscation we can either use any third part tool or dotfuscator tool provided by Microsoft.
What is the difference between Convert.ToString and .ToString() method ?
The Convert.ToString("") will handle NULL values where as .ToString() will not.
What is Native Image Generator (Ngen.exe)?
The Native Image Generator utility (Ngen.exe) allows you to run the JIT compiler on your assembly's MSIL and generate native machine code which is cached to disk. After the image is created .NET runtime will use the image to run the code rather than from the hard disk. Running Ngen.exe on an assembly potentially allows the assembly to load and execute faster, because it restores code and data structures from the native image cache rather than generating them dynamically.

If we have two version of same assembly in GAC how do we make a choice ?
The choice of version can be made in the config file. Below code shows an example

What is AL (Assembly Linker)?
As you are aware assembly can be of either single file type or it can contain multiple file type. When you want to add a file to assembly you can use assebmly linker.
What are the key elements of an assembly?
Portable Executable header , Metadata, MSIL
How many manifest an assembly can have?
One
What are Generations in Garbage collection.
Garbage collection has 3 generations. Generation 0, Generation 1 and Generation 2. When the object is first created it is created in the Generatin 0. When the garbage collector runs it clears the unused memories and pushes the objects that are in use to Generation 1. This way Garbage collector makes more space for the new objects in Generation 0. When the Generation 1 is full again it runs and moves the unused items to generation 2. The objects in Generation 0 are newly created and the one in Generation 1 are the oldest.
Other ASP.Net related interview questions are available at
Set 1 of ASP.Net Interview questions or Asp.Net FAQs

No comments: