.NET Frame work consist of two parts
* Common language runtime(CLR)
* Framework Class Library(FCL)
Advantage of CLR and FCL
* Consistent programming model - oops
* Simplified programming model - frees developer from knowledge of registry, GUIDS, AddRef..
* Run once - run always
* Simplified Deployement
* Wide platform reach - ny machine that has CLR installed.
* Programming language integration - ny language
* Automatic Memory Management - garbage collection
* Type safety
* Rich debugging support
* Exeption handling
* Security
* Interoperability - access existing COM and win32 func in existing Dlls
What is the advantage of using one programming language over other ?
i think of compilers as syntax checkers and correct code analyzers. Expressing your logic
is very important. different developers had different background before switching to .NET
so inorder to make them more comfortable with programming languages.
A MANAGED MODULE is a standard windows protable executable(PE) file that requires the CLR
to execute.
Parts of Managed Module
* PE Header - type of file-dll,exe,gui,cui, modified,access,creation time
* CLR Header - entry point, CLR target version, location size of resources, metadata and flags
* Metadata - mainly 2 tables-tables that describe the types and members defined/referenced in ur source code
* IL code - code produced by compiler
5 Uses of Metadata
* Intellisense
* Removes the need of Header files and Library files
* Garbage coller to track the life time of object
* Use during serialization and deserialization of an object
* By Code verfication process to ensure type safe operations
Multiple Managed modules + resource files = 1 Assembly file(modules + Manifest)
.NET Framework installed or not check for MSCoreEE.dll file in system32 folder.
MSCorEE.dll - Microsoft Component Object Runtime Execution Engine.
Click exe file - read PE header - 6 byte x86 stub function - JMP _CorExeMain/JMP _CorDllMain - loads MSCorEE.dll - executes _CorExeMain - initialize CLR - read CLR Header - locate Main entry point
6-byte x86 stub functions are ignored on machines running Windows XP and the Windows .NET Server Family
IL Assembler - ILAsm.exe
IL Disassembler - ILDasm.exe
New function - JITCompiler - searches assembly metadata for methods IL- compiles it.
Managed Code outperforms unmanaged code when -:
* JIT complier could detect that the application is running on a pentium 4 and produce
* native code that takes advantage of any special instructions offered by the pentium-4.
* NGen.exe tool - compiles assembly IL code into native code and saves resulting code
* to a file in the disk.
Verification - safe - throw exception System.Security.VerifierException- also tool PEVerify.exe
CTS - describs how types are defined and how they behave
Property - validate input parameters and object state before accessing the value and calculate
* a value only when necessary
IL defines 6 visibles types
* Private - same class
* Family - protected - derived class
* Public - any class
* Assembly - internal - Friend - any class same assembly
* Family or assembly - protected internal - Protected Friend same assembly or derived types in diff assembly
* Family and assembly - derived type in same assembly - not supported
if an unnested type isn't explicitly marked, C# and VB both default to Assembly(internal/Friend)
CLS - Minimum set of features that a compiler must support to target CLR.
Windows - security is based around a users identity
.NET Framework - code access security - based around an assembly's identity
MSCorLib.dll - it contains the definitions of all the core .NET Framework class Library (FCL) types, such as Object, Int32, String and so on.
Assembly - An assembly is a collection of one or more files containing type definitions and resource files.
Manifest - it is another set of metadata tables that basically contain the name of the files that are part of the assembly and makes the assembly self describing.
CLR always loads the file that contains the manifest metadata talbes first and then uses the manifest to get the names of the other files that are in the assembly.
/t:exe, /t:winexe, /t:library - assembly is produced
/t:module - DLL PE file without manifest, must be added to assembly to access its types
AL.exe - Assembly Linker Utility - creates assembly consisting of modules built from different compilers or to build resource only assembly(satellite assembly)
AssemblyInfo.cs - assembly specific information.
3 custom attribute for versioning - AssemblyVersion is main - CLR uses this version number when binding to strongly named assemblies.
* uniquely identify an assembly. format of version number - 4 fields.
* Major Number
* Minor Number
* Build Number - increments with every build
* Revision Number
Culture attribute - for a specific language - 2 fields - Primary Tag and secondary Tag - en (none) and en US
* Culture Neutral - Assembly that isnt assigned a culture
* Satellite Assembly - Assemblies that contain only culture specific resources and no code - AL.exe tool
* you access the satellite assembly's resources using the System.Resources.ResourceManager
* you can also specify the Culture using the System.Reflection.AssemblyCultureAttribute custom attribute [assembly:AssemblyCulture("en-US")]
Two kinds of Assemblies - Weakly named assemblies and strong named assemblies.
* Difference - strong named assembly is signed with publisher's public/private key pair that uniquely identfies the assemblies publisher.
Two ways of deployment
* Privately deployed assemblies - Assemblies deployed to the same application directory - both weak and strong named assembly
* Globally deployed - assemblies deployed the CLR known location - stong named assembly
A strong named assembly consist of four attributes that uniquely indentify the asembly
* FileName(without extention)
* VersionNumber
* culture identity
* Public key token
SN.exe - Strong Name Utility - generate public/private key pair
* Public key Token is 64 bit hash of public key
to create strong named assembly - use System.Reflection.AssemblyKeyFileAttribute in ur source code
* [assembly:AssemblyKeyFile("Mycompany.Keys)]
* signs assembly with private key and embeds public key in the manifest - SHA-1 algorithm - PE file's entire contents are hashed after built
GAC - C:\Windows\Assembly\GAC
* Use always GACUtil.exe to install a strong name assembly into GAC.
CLR compares hash value when assembly is loaded other than GAC - performance hit
Delayed Signing - developing and testing ur assembly , gaining access to secure private key can be hassle - always copying in GAC
* it allows you to build an assembly using only public key - extract public key in a file - use both keys which packaging n installing
* DelaySignAttribute
Wednesday, December 3, 2008
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment