Custom Search

Wednesday, February 27, 2013

Questions and Answers for .net

Questions and Answers for .net
1. What is application domain?

The primary purpose of application domain is to isolate an application from other application. Win32 process provides isolation but in distinct memory address spaces. This is effective but it is expensive and doesn't scale well. The .NET runtime enforces app domain isolation by keeping control over the use of memory.

All memory in the app domain is managed by the .net runtime so the runtime can ensure that app domain do not access each other's memory. Objects in different application domains communicate either by transporting copies of objects across application domain boundries or by using a proxy to exchange messages.


2. What is Remoting in .NET?

.NET Remoting offers much more complex functionality including support for passing objects by values or by references, callbacks & multiple objects activation ^ life cycle management policy.
In order to use Remoting a client need to build using .NET.


3. What is Property?


A property is a method or pair of methods that are exposed to the outside world as if they are fields.


4. Can a DataAdapter.Fill method take DataTable as parameter or it works only for DataSet?


It has 5 different overloads and of course it can take DataSet as well as DataTable as parameter to fill data in from database.


5. What is typed dataset ?


A typed dataset is very much similar to a normal dataset. But the only difference is that the sehema is already present for the same. Hence any mismatch in the column will generate compile time errors rather than runtime error as in the case of normal dataset. Also accessing the column value is much easier than the normal dataset as the column definition will be available in the schema.


6. Can you place two .dll files with the same name in GAC (Global Assembly Cache)?


Yes, provided both have different versions.

GAC is a Folder that contains .dll that have strong name. So we can keep myproject.dll and myproject.dll two files into GAC with different version like 1.0.0.0 and 1.0.0.1


7. What's the difference between private and shared assembly?


Private Assembly is used inside an application only and does not have to be identified by a strong name.

Shared Assembly can be used by multiple applications and has to have a strong name


8. What is JIT (Just-in-time) Compiler ?

Just-in-time compiler is a compiler used to convert the Commmon Intermediate Language (CIL) code into native code (also called machine code) that is processed by machine.

A little description

While compiling of .NET program, its code is converted into Common Intermediate Language code that is done by Common Language Runtime.
But while executing the program this CIL code is converted into Machine code or Native code that is done by JIT Compiler.


9. What is Managed and Unmanaged code?
                            
Managed Code is what Visual Basic .NET and C# compilers create. It compiles to Intermediate Language (IL), not to machine code that could run directly on your computer. The IL is kept in a file called an assembly, along with metadata that describes the classes, methods, and attributes (such as security requirements) of the code you've created. This assembly is the one-stop-shopping unit of deployment in the .NET world. You copy it to another server to deploy the assembly there—and often that copying is the only step required in the deployment.

Unmanaged code is what you use to make before Visual Studio .NET 2002 was released. Visual Basic 6, Visual C++ 6, heck, even that 15-year old C compiler you may still have kicking around on your hard drive all produced unmanaged code. It compiled directly to machine code that ran on the machine where you compiled it—and on other machines as long as they had the same chip, or nearly the same. It didn't get services such as security or memory management from an invisible runtime; it got them from the operating system. And importantly, it got them from the operating system explicitly, by asking for them, usually by calling an API provided in the Windows SDK. More recent unmanaged applications got operating system services through COM calls.


                            

10. What is the difference between Namespace and Assembly?


Namespace:
1. It is a Collection of names wherein each name is Unique.
2. They form the logical boundary for a Group of classes.
3. Namespace must be specified in Project-Properties.

Assembly:
1. It is an Output Unit. It is a unit of Deployment & a unit of versioning. Assemblies contain MSIL code.
2. Assemblies are Self-Describing. [e.g. metadata,manifest]
3. An assembly is the primary building block of a .NET Framework application. It is a collection of functionality that is built, versioned, and deployed as a single implementation unit (as one or more files). All managed types and resources are marked either as accessible only within their implementation unit, or by code outside that unit.


11. What is Manifest?


The manifest describes the assembly, providing the logical attributes shared by all the modules and all components in the assembly. The manifest contains the assembly name, version number, locale and an optional strong name that uniquely identifying the assembly.


12. What is Metadata?


Metadata is the complete way of describing what is in a .NET assembly. Digging into the metadata yields the types available in that assembly, viz. classes, interfaces, enums, structs, etc., and their containing namespaces, the name of each type, its visibility/scope, its base class, the interfaces it implemented, its methods and their scope, and each method’s parameters, type’s properties, and so on


13. What is CODE Access security?


Code Access Security (CAS), in the Microsoft .NET framework, is Microsoft's solution to prevent untrusted code from performing privileged actions.

It performs following function

1. Defines permissions and permission sets that represent the right to access various system resources.
2. Enables administrators to configure security policy by associating sets of permissions with groups of code (code groups).
3. Enables code to request the permissions it requires in order to run, as well as the permissions that would be useful to have, and specifies which permissions the code must never have.
4. Grants permissions to each assembly that is loaded, based on the permissions requested by the code and on the operations permitted by security policy.
5. Enables code to demand that its callers have specific permissions.
6. Enables code to demand that its callers possess a digital signature, thus allowing only callers from a particular organization or site to call the protected code.
7. Enforces restrictions on code at run time by comparing the granted permissions of every caller on the call stack to the permissions that callers must have.


14. What’s difference between System.SystemException and System.ApplicationException?


The difference between ApplicationException and SystemException is that SystemExceptions are thrown by the CLR, and ApplicationExceptions are thrown by Applications.


15. What is multi-threading?


It is basically trying to do more than one thing at a time within a process.

There are two main ways of multi-threading which .NET encourages: starting your own threads with ThreadStart delegates, and using the ThreadPool class either directly (using ThreadPool.QueueUserWorkItem) or indirectly using asynchronous methods (such as Stream.BeginRead, or calling BeginInvoke on any delegate).


16. What the way to stop a long running thread ?


System.Threading.Thread.Abort


17. What is the diffeernce between Overload and Override?


Overload is the another version of the same function into the class. There can be different parameters, return type in overload functions.
Override is entirely overriding the base class function and creating our own version in the child class. Base class and child class function name and return type should be same.


18. How many web.configs can an application have?



An application can have multiple web.config files but in different directories ... mean each and every directory can have a web.config file.


19. Where do you store connection string?
         

Database connection string can be stored in the web config file.


20. What is abstract class


Abstract class cannot be instantiated instead it has to be inherited. The methods in abstract class can be overridetn in the child class

1 comment:

  1. Hi,

    Recently I came across some great articles on your site.
    The other day, I was discussing (http://phpprogrammings.blogspot.in/2013/02/questions-and-answers.html)with my colleagues and they suggested I submit an article of my own. Your site is just perfect for what I have written!
    Would it be ok to submit the article? It is free of charge, of course!

    Let me know what you think
    Contact me at anelieivanova@gmail.com

    Regards
    Anelie Ivanova

    ReplyDelete