Sie sind auf Seite 1von 8

ASSIGNMENT-1

1.a.Explain the .Net assembly,its contents?Also explain each of


its types.
Regardless of which . NET language you choose to program with, understand that despite
the fact that .NET binaries take the same file extension as COM servers and unmanaged
Win32 bin a ries (*.dll or *.exe),they have absolutely no internal. Perhaps most important,
.NET binaries do not contain platform-specific instructions, but rather platform-agnostic
intermediate language (IL) and type metadata. Figure 1-2 shows the big picture of t h e story
thus far.

An Overview of .NET Assemblies


*.dll .NET binaries do not export methods to facilitate communications with the
COM
.NET binaries are not described using COM type libraries and are not
registered into the
system registry.
.NET binaries do not contain platform-specific instructions, but rather platformagnostic
intermediate
language and type metadata.
When a *.dll or *.exe has been created using a .NET-aware compiler, the
resulting
module is bundled into
an assembly.
An assembly contains CIL code, which is conceptually similar to Java
bytecode in that it
is not compiled to
platform-specific instructions until absolutely necessary.
6]Assemblies also contain metadata. .NET metadata is a dramatic
improvement to COM
type metadata.
.NET metadata is always present and is automatically generated by a
given .NET-aware
compiler.
Assemblies themselves are also described using metadata, which is officially
termed a
manifest
The manifest contains information about the current version of the assembly,
culture

information, and a list of all externally referenced assemblies that are required for
proper execution.
TYPES:
Single-File and Multifile Assemblies

Single-file assemblies contain all the necessary CIL, metadata and manifest in
a single
well-defined package. (Package means folder).
On the other hand, multi-file assemblies are composed of numerous .NET
binaries,
each of which is termed a module.
In a multiple assembly, one of the module (termed as primary module) must
contain
the assembly-manifest.
The other related modules contain
a module-level manifest, CIL and type metadata.
The primary-module maintains the set of required secondary-modules within the
assembly manifest.
Multifile assemblies are used when different modules of the application
are
written in different languages.

1.b.Describe namespaces?Explain any four namespaces .


A namespace is a grouping of related types contained in an assembly.Keep all the
types within the base class libraries well organized, the .NET platform makes
possible by of the namespace concept.
1.System:Within System you find numerous useful types dealing with intrinsic
data,mathematical computations,random number generation,environment variable
and garbage collections as well as a number commenly used exception and
attributes. System.Collections:these namespace defines a number of stock container
onjects. System.Collection.generic:array list,queues and linked lists
2.System.threading:this name space defines types used to build multithreaded
applications
3.System.web:A number of namespaces are specifically geard towards the
development of .NET web applicatons
4.System.Runtime.InteropServices:This namespace provides the facility to allow
the .NET types to interact with unmanaged code and viceversa.

1.c.Explain CLR.Illustrate the work flow that take place between


the source code, given .NET compiler and the .NET execution
engine.
Ans:
Common Language Runtime:The primary role of the CLR is to locate, load, and
manage .NET types on your behalf. The CLR also takes care of a number of lowlevel details such as memory management and performing security checks.
1].NET runtime provides a single well-defined runtime layer that is shared by all
languages and platformsthat are .NET-aware.
2]The crux of the CLR is physically representedamed mscoree.dll . by a library
nWhen a assembly is referenced for use, mscoree.dll is loaded automatically, which
in turn loads the required assembly into memory. The runtime engine is responsible
for a number of tasks.
They are:
1]It is the entity in charge of resolving the location of an assembly and finding the

requested type within the binary by reading the contained metadata.


2]The CLR then lays out the type in memory, compiles the associated CIL into
platformspecific instructions, performs any necessary security checks, and then
executes the code in question.
3]The CLR will also interact with the types contained within the .NET base class
libraries when required.Although the entire base class library has been broken into a
number of discrete assemblies, the key assembly is mscorlib.dll. mscorlib.dll
contains a large number of core types that encapsulate a wide variety of common
programming tasks as well as the core data types used by all .NET languages.
When you build .NET solutions, you automatically have access to this particular
assembly.The workflow that takes place between your source code given .NET
compiler, and the .NET execution engine.
2.a.Create a c# program tp generate fibonacci series upto N. Value of N is
read from console.
using System;
class program
{
static void Main(string[] args)
{ int n,c;
int a=0;
int b=1;
Console.WriteLine(How many fibonacci numbers you want to generate);
n=int .parse(Console.ReadLine());
Console.WriteLine(Fibonacci numbers are\n);
Console.Wrrite({0}\t{1}\t,a,b);
for(int i=0;i<n-2;i++)
{
c=a+b;
Console.Write({0}\t,c);
a=b;b=c;
}
Console.ReadLine();
}}
2.b.Explain the following,with respect to compilation of the C# program in
command prompt.
a.referencing external assemblies
b.compiling multiple source files
c.response files
d.generating bug reports
a.To refer the external assemblies in a current applications use flag /reference or /r
ex:/r:System.Windows.Forms.dll TestApp.cs
b.We compile multiple source file using the command
csc /r:System.Windows.Forms.dll TestApp.cs HelloMsg.cs

or csc /r:System.Windows.Forms.dll *.cs


c.To reference numerous external assemblies using csc.exe, simply list each
assembly using a semicolon-delimited list. You dont need to specify multiple external
assemblies for the current example, but some sample usage follows:
csc /r:System.Windows.Forms.dll;System.Drawing.dll *.cs
d.The raw C# compiler provides a helpful flag named /bugreport.
csc /bugreport:bugs.txt *.cs
When you specify /bugreport, you will be prompted to enter corrective information for
the possible errors at hand, which will be saved into the file you specify.
2.c.Explain the building of a C# application using command line compiler
CSC.exe.
To build a simple single file assembly named TestApp.exe using the C#
commandlinecompiler and Notepad. First, you need some source code. Open
Notepad and enter the following:
using System;
class TestApp
{
public static void Main()
{
Console.WriteLine(testing! 1,2,3);
}
}
save the file in a convenient location as TestApp.cs.
2.d.Describe the building blocks of .NET frame work?Show their
relationship,with a neat block diagram.
Some of the benefits provided by .NET, lets preview three key entities that make it
all possible: the CLR, CTS, and CLS. Common language runtime, or CLR:The
primary role of the CLR is to locate, load, and manage .NET types on your behalf.
The CLR also takes care of a number of low-level details such as memory
management and performing security checks. Common Type System or CTS:The
CTS specification fully describes all possible data types and programming constructs
supported by the runtime, specifies how these entities can interact with each other,
and details how they are represented in the .NET metadata format. Common
Language Specification or CLS:The CLS is a related specification that defines a
subset of common types and programming constructs that all .NET programming
languages can agree on.Thus, if you build .NET types that only expose CLScompliant features, you can rest assured that all .NET-aware languages can
consume them.
3.a.Create C# program to display the following information using system
environment class
a.current directory of application
b.operating system versionsc.logical drivers

using System;
class PlatformSpy
{
public static int Main(string[] args)
{
Console.WriteLine("Current OS: {0} ",Environment.OSVersion);
Console.WriteLine("Current Directory: {0} ",Environment.CurrentDirectory);
string[] drives = Environment.GetLogicalDrives();
for(int i = 0; i < drives.Length; i++)
Console.WriteLine("Drive {0} : {1} ", i, drives[i]);
Console.WriteLine("Current version of .NET: {0} ",Environment.Version);
return 0;
}
}
3.b.Explain the problems with earlier programming languages,and
justify .NET provides solution,for it.
Life As a C/Win32 API Programmer:
Developing software for the Windows family of operating systems involved using
the C programming language in conjunction with the Windows application
programming interface.
C is a very terse language, in developers does manual memory management,
ugly
pointer arithmetic, and ugly syntactical constructs.
C is a structured language; it lacks the benefits provided by the object-oriented
approach.
Life As a C++/MFC Programmer:
C++ can be thought of as an object-oriented layer on top of C. Thus, even
though
C++ programmers benefit from the famed pillars of OOP ,they are still at the mercy
of the painful aspects of the C language
The Microsoft Foundation Classes provides the developer with a set of C++
classes that facilitate the construction of Win32 applications. The main role of
MFC is towrap a sane subset of the raw Win32 API behind a number of
classes, magic
macros, and numerous code-generation tools.
C++ programming remains a difficult and error-prone experience, given its
historical roots in C.
Life As a Visual Basic 6.0 Programmer:
VB6 is popular due to its ability to build complex user interfaces, code libraries,
and
data access logic with minimal fuss and bother.Even more than MFC, VB6 hides the
complexities of the raw Win32 API from view using a number of integrated code
wizards, intrinsic data types, classes, and VB-specific functions
VB6 is not a fully object-oriented language; rather, it is object aware.

For example, VB6 does not allow the programmer to establish is-a
relationships
between types and has no intrinsic support for parameterized class construction.
VB6 doesnt provide the ability to build multithreaded applications unless you are
willing to drop down to low-level Win32 API calls.
Life As a Java/J2EE Programmer
The Java programming language is completely object oriented and has its
syntactic
roots in C++.
Its support for platform independence.
Java cleans up many unsavory syntactical aspects of C++. Java provides
programmers with a large number of predefined packages that contain various
type definitions.
Using these types, Java programmers are able to build 100% Pure Java
applications complete with database connectivity, messaging support, webenabled
front ends, and a rich user interface.
Java is a very elegant language; one potential problem is you must use Java
front-back during the development cycle.
Life As a COM Programmer:
The Component Object Model was Microsofts previous application development
framework.
COM is an architecture that says in effect, If you build your classes in
accordance
with the rules of COM, you end up with a block of reusable binary code.
The beauty of a binary COM server is that it can be accessed in a
languageindependent
manner.
C++ programmers can build COM classes that can be used by VB6. Delphi
programmers can use COM classes built using C.
COM is its location-transparent nature Using constructs such as application
identifiers , stubs, proxies, and the COM runtime environment, programmers can
avoid the need to work with raw sockets, RPC calls, and other low-level details.
Life As a Windows DNA Programmer:
Building a web application using COM-based Windows Distributed interNet
Applications
Architecture is also quite complex.
Some of this complexity is due to the simple fact that Windows DNA requires the
use of numerous technologies and languages . One problem is that many of these
technologies are completely unrelated from a syntactic point of view
3.c.Explain the varrious output options available with C# compiler.
1./out:This option is used to specify the name of the assembly to be created.By
default,the
assembly name is same as the name of the initial input *.cs file.

Ex:cs /out:CoolApp.exe TestApp.cs


2./target:exe or /t:exe flag: This option builds an executable console application and
create an assmbly with exetension *.exe
ex:csc/t:ex TestApp.cs
3./target:library:This option builds a single file *.dll assembly
ex:csc /target:library File.cs

4./target:module:This option builds a module.Modules are elements of multifile


assemblies
ex:csc/target:module File.cs
5./target:winexe:option causes the compiler to create an executable,windows
program.
Ex:csc /target:winexe in.cs

Das könnte Ihnen auch gefallen