The. NET Framework for Java Programmers---3 (good)

Source: Internet
Author: User
Tags command line file system stub

Assemblies

An assembly was the functional unit of sharing and reuse in the Common Language. It is the equivalent of JAR (Java Archive) files of Java.
Assembly is a collection the physical files package in a. CAB format or newly introduced. MSI file format. The assemblies contained in a. CAB or. MSI files are called static assemblies, they include. NET Framework types (interfaces and classes) as as a R the Assembly (bitmaps, JPEG files, resource files, etc.). They also include metadata that eliminates the need of IDL file descriptors, which were required for describing COM compo Nents.
The Common Language Runtime also provide API ' s that script engines with to create dynamic assemblies when executing scripts . These assemblies are run directly and are never to disk.
Microsoft has greatly diminished of Windows Registry system with Introduction to assemblies concept, which is Adaptation of Java ' s JAR deployment technology.
Assemblies is a adaptation, but not a copy of the Java ' s JAR technology. It has been improved upon in some ways, for example it has introduced a versioning system. However, since the. NET framework is skewed towards the Windows architecture some of the Java ' s JAR portability features M Ay have been sacrificed.
Again, similar to JAR files, the assemblies too contain a entity called Manifest. However, manifest in the. NET framework plays somewhat wider role. Manifest is a metadata describing the inter-relationship between the entities contained in the assemblies like managed cod E, images and multimedia resources. Manifest also specifies versioning information.
The manifest is basically a deployment descriptor has an XML syntax. Java programmers can relate it with EE (Java 2 Enterprise Edition) deployment descriptors for EjB (Enterprise Java Beans ) applications.
The Microsoft documentation stress that assemblies are \ Logical Dlls\. This May is a reasonable paradigm for VB or C + + programmers, but Java programmers'll find it easier, if we visualize as Semblies as an extension of JAR concept. However, unlike JAR, each assembly can have only one entry point defined, which can be either DllMain, WinMain, or Main.
As stated earlier, assemblies have a manifest metadata. This contains version and digitally signed information. This is purports to implement version control and authentication of the software developer. Version and authentication procedure is carried out by the runtime during loading the assembly into the code execution are A.
Again, much like Java ' s trusted lib. Concept,. NET assemblies can be placed into secured area called Global Assembly Cache. This are equivalent to trusted class path of Java. Only system administrators can install or deinstall assemblies from the global assembly cache. There is a place for downloaded or transient assemblies called downloaded assembly Cache. The assemblies loaded from global assembly cache run outside the sandbox and have faster load time as so as enjoy more F Reedom to access file system resources. The assemblies loaded from the downloaded cache area are subject to over security checks, therefore are slower to load and Since they run inside the sandbox; Enjoy much less privileges.
Assemblies manifests also contain information regarding of code by sharing different and applications application.
To summarize, the operating System can have multiple applications running simultaneously, each such application occupies a Separate WIN32 process and can contain multiple application Domains. An application Domain can is constructed from multiple assemblies.

Execution

The Common Language Runtime provides the infrastructure that enables execution to take place as as a variety of servi Ces that can is used during execution. Before a can be executed, it must is compiled to processor code. Each of the for which MSIL has been generated are JIT compiled when it was called for the "the", then executed. The next time is executed, the existing JIT compiled native the code is executed. The process of JIT compiling and then executing the code is repeated until execution is complete.
As mentioned earlier, the recompilation can is avoided by compiling the code during installation into native executable co De.
During execution, managed code receives services such as automatic memory management, security, interoperability with UNMA Naged code, cross language debugging support, and enhanced deployment and versioning.

JIT compilation

Before intermediate Language (IL) can be executed, it must is converted by the A. NET Framework Just in Time (JIT) compiler to Native code, which is CPU specific code this runs on the same computer architecture this JIT compiler is running on.
Microsoft ' s designers insist that runtime never interprets any language, it always executes code, only native On to native form is deferred. Even the scripting languages like VBScript are now compiled and executed!
The idea behind JIT compilation recognizes the fact which some code may never get called during; Therefore, rather than using time and memory to convert all of the "MSIL in a" PE (portable executable) file to native code, It converts the intermediate Language as it is needed during execution and store the resulting native code so this it is Accessible for subsequent calls.
The loader creates and attaches a stub to all of the type ' s methods when the type is loaded; On the initial call to the "method", the stub passes control to the JIT compiler, which converts the "MSIL for" To native code and modifies the stub to direct execution to the location of the native code. Subsequent calls of the JIT compiled method proceed directly to the native code this was previously generated, reducing th E time it takes to JIT compile and execute the code.
The compilation process (JIT or during installation time) converts the intermediate Language (IL) to native code. The code however, must pass a verification process. Verification examines the intermediate Language (IL) and metadata to the-whether the code is type safe, which is, it access ES only the authorized memory locations, identities are what they claim to being and reference to a type are compatible with T He type referenced. These features protects the application from bugs and viruses.
During the verification process, intermediate Language (IL) code is examined in a attempt to confirm that the code can AC Cess memory locations and call methods only through properly defined.
Due to design limitation of the some programming languages, like ' C ', it's compilers may is able to produce verifiable ty PE safe codes, such codes can only is executed from trusted area.

Runtime Hosts

The runtime is typically started and managed by environments like ASP.net, IE or the Windows Shell. These hosting environments run managed code on behalf of the user and take advantage of the application isolation provided by application domains. In fact it's the host that determines where the application domain boundaries lie and in what application domain user cod E is run in. The Common Language Runtime provides a set of classes and interfaces used by hosts to create and manage application Domain S.
There are five Common Language Runtime hosts:
Asp.net-asp.net creates application domains to run user code. Application domains are created per application as defined by the Web server.
Internet Explorer-ie creates a application domain per site.
Windows Shell Exe-each application that's launched from the command line runs in a separate application domain.
VBA-VBA runs the script code contained in an Office document in a application domain.
Windows Forms designer-the Windows Forms Designer places each form the "user is" building in a separate application domain . When the user edits the "form" and rebuilds, Windows Forms shuts down the old application domain, recompiles the code and RU NS it in a new application domain.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.