The document compares and contrasts namespaces, assemblies, exceptions, components, and assembly types.
It discusses that namespaces logically group types, assemblies physically group code. System exceptions are generic while application exceptions are customized. COM uses interfaces while .NET uses objects. Private assemblies are only used by one application while public assemblies can be used by multiple applications.
Take control of your SAP testing with UiPath Test Suite
Difference between Namespace, Assembly, COM Component, .NET Component, Private Assembly and Public Assembly
1. 1.Difference between Namespace and Assembly
S.No Namespace Assembly
1 Namespace is the logical naming Scope for a particular type is defined at
decided at design time by the run time using Assembly.
developer.
2 Namespace contains set of unique Assembly contains code of the form
names. MSIL ( Microsoft Intermediate
Language)
3 Classes available in your program Logical units are physically grouped
will be logically grouped together together as assembly.
under a namespace.
4 Namespace can include multiple An assembly can contain types
assemblies. belonging to different namespaces.
5 Namespace doesn't have any Assembly can be classified as private
classification. 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.
6 Namespaces have to be mentioned Assemblies need not be explicitly
in Project-Properties. specified. They are automatically
described in metadata and manifest
files.
7 Namespaces can be nested. For Such nesting is not permissible in
example: assemblies.
namespace sampleApp1 {
namespace SampleApp2 {
class sampleClass {
…
}
}
}
8 Namespace is the one which you Creating an assembly on your own is
directly specify in your code. A not as simple as you create a
simple example for namespace is namespace. If you want to package the
shown below: code shown as an example for the
namespace sampleNamespace { namespace into an assembly, then you
class sampleClass { have to follow the steps shown below:
public void displayMsg() { " Generate a key file inside the same
Console.WriteLine("In folder where you have placed the code
sampleClass"); by typing the following statement in
} the command prompt:
} sn -k sampleKey.key
} " Sign your code component with this
2. In this example, key. Assume that your code component
sampleNamespace is the is named as sampleClass.cs. Now use
namespace you have created and the following command:
sampleClass is within the scope of csc sampleClass.cs /t:library
this namespace. /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();
obj.displayMsg();
}
" 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:<path of your
assembly>
" Now if you execute testClass.cs, you
should get the following output:
In sampleClass
2.Difference between System Exception and Application Exception
S.No System Exception Application Exception
1 CLR throws system exception Application throws application
exception
2 System exceptions are generic in Application exceptions are not generic.
nature Each application exception has its own
customized meaning
3 Each system exception has a Application exceptions do not have a
meaning. You can directly use meaning for themselves. You have to
them or you can derive new ones explicitly derive from them and create
by inheriting System.Exception your own custom exceptions specific
to your application
4 Example for system exceptions Example for application exceptions
include SqlException, include SharePointException,
StackOverflowException CmsException
3. 3.Difference between COM and .NET Component
S.No COM Component .NET Component
1 Interface based communication Object based communication
2 Reference count will be used to Garbage Collector to manage memory
manage memory
3 Binary Standard objects Type Standard objects
4 Objects are created by Objects are created by normal new
coCreateInstance operator
5 Object info resides in Type library Object info resides in assembly files
6 HRESULT will be returned Exceptions will be returned
COM=HRESULT will be returned
4.Difference between Private Assembly and Public Assembly
S.No Private Assembly Public Assembly
1 Private assembly can be used by Public assembly can be used by
only one application. multiple applications.
2 Private assembly will be stored in Public assembly is stored in GAC
the specific application's directory (Global Assembly Cache).
or sub-directory.
3 There is no other name for private Public assembly is also termed as
assembly. shared assembly.
4 Strong name is not required for Strong name has to be created for
private assembly. public assembly.
5 Private assembly doesn't have any Public assembly should strictly enforce
version constraint. version constraint.
6 By default, all assemblies you An example to public assembly is the
create are examples of private actuate report classes which can be
assembly. Only when you imported in the library and used by any
associate a strong name to it and application that prefers to implement
store it in GAC, it becomes a actuate reports.
public assembly.
And, further updates on difference between questions and answers, please visit my blog @
http://onlydifferencefaqs.blogspot.in/