DOTNET Framework Difference FAQs-3

1.Difference between Namespace and Assembly
Namespace is the logical naming decided at design time by the developer.
Scope for a particular type is defined at run time using Assembly.
Namespace contains set of unique names.
Assembly contains code of the form MSIL ( Microsoft Intermediate Language)
Classes available in your program will be logically grouped together under a namespace.
Logical units are physically grouped together as assembly.
Namespace can include multiple assemblies.
An assembly can contain types belonging to different namespaces.
Namespace doesn't have any classification.
Assembly can be classified as private assembly and public assembly. Private assembly is specific to a single application but shared/public assembly contains libraries which can be used by multiple applications.
Namespaces have to be mentioned in Project-Properties.
Assemblies need not be explicitly specified. They are automatically described in metadata and manifest files.
Namespaces can be nested. For example:
namespace sampleApp1 {
namespace SampleApp2 {
class sampleClass {

Such nesting is not permissible in assemblies.
Namespace is the one which you directly specify in your code. A simple example for namespace is shown below:
namespace sampleNamespace {
class sampleClass {
public void displayMsg() {
Console.WriteLine("In sampleClass");
In this example, sampleNamespace is the namespace you have created and sampleClass is within the scope of this namespace.
Creating an assembly on your own is not as simple as you create a namespace. If you want to package the code shown as an example for the namespace into an assembly, then you have to follow the steps shown below:
" Generate a key file inside the same folder where you have placed the code by typing the following statement in the command prompt:
sn -k sampleKey.key
" Sign your code component with this key. Assume that your code component is named as sampleClass.cs. Now use the following command:
csc sampleClass.cs /t:library /a.keyfile:sampleKey.key
" Place your signed assembly inside GAC using AL Utility:
AL /i: sampleClass.dll
" Now create a code that accesses the code in your assembly:
Using System;
Using sampleNamespace;
public class testClass {
sampleClass obj = new sampleClass();
" To test if your assembly got created and to test if the above code is working, compile the above code using the following statement:
csc testClass.cs /t:exe /r:
" Now if you execute testClass.cs, you should get the following output:
In sampleClass
2.Difference between System Exception and Application Exception
System Exception Application Exception
CLR throws system exception
Application throws application exception
System exceptions are generic in nature
Application exceptions are not generic. Each application exception has its own customized meaning
Each system exception has a meaning. You can directly use them or you can derive new ones by inheriting System.Exception
Application exceptions do not have a meaning for themselves. You have to explicitly derive from them and create your own custom exceptions specific to your application
Example for system exceptions include SqlException, StackOverflowException
Example for application exceptions include SharePointException, CmsException
3.Difference between COM and .NET Component
COM Component .NET Component
Interface based communication
Object based communication
Reference count will be used to manage memory
Garbage Collector to manage memory
Binary Standard objects
Type Standard objects
Objects are created by coCreateInstance

Objects are created by normal new operator

Object info resides in Type library
Object info resides in assembly files
HRESULT will be returned
Exceptions will be returned     
COM=HRESULT will be returned
4.Difference between Private Assembly and Public Assembly
Private Assembly Public Assembly
Private assembly can be used by only one application. Public assembly can be used by multiple applications.
Private assembly will be stored in the specific application's directory or sub-directory.
Public assembly is stored in GAC (Global Assembly Cache).
There is no other name for private assembly. Public assembly is also termed as shared assembly.
Strong name is not required for private assembly.
Strong name has to be created for public assembly.
Private assembly doesn't have any version constraint.
Public assembly should strictly enforce version constraint.
By default, all assemblies you create are examples of private assembly. Only when you associate a strong name to it and store it in GAC, it becomes a public assembly.
An example to public assembly is the actuate report classes which can be imported in the library and used by any application that prefers to implement actuate reports.

1 comment:

  1. very nice,but if any one gives some more explaination it will some more better to under stand.thanks... Hire .Net Developers India