Book notes on. NET4.0 Object-Oriented Programming-Chapter 1 assembly

Source: Internet
Author: User

Chapter 2Assembly

[Overview]: an Assembly plays an important role in. NET development. It is the basic construction block of. NET applications. This chapter mainly introduces the basic knowledge of assembly, componentized development based on assembly, and interoperability assembly.

 Section 1Basic Assembly knowledge

1, Assembly generation and use.

Assembly A (Assembly) is. NET Framework. It can contain an unlimited number of types. Its carrier is one or more DLL files, or an executable EXE file. Generally, the Class Library Project template provided by Visual Studio is used to create an assembly.

B. If you need to use the type in a specific assembly, you need to add a "Reference" to this Assembly ".

The C using statement imports the namespace in the Assembly.

2The internal structure of the Assembly.

 

A. IL code: the code will be instantly compiled as local code when the program is running.

B. Resource: compare to a file or a String constant.

C. Type Metadata: Describes to the outside world information such as "How many classes I have and how many methods and fields each class has.

D. Assembly metadata: an assembly may be distributed in multiple files. Therefore, a file list must be included to declare "which files are I distributed in ".

E. Because of the existence of metadata, the Assembly becomes "self-explanatory" and the Registry is no longer required. You can directly copy the Assembly to complete the installation.

Section 2Assembly and component development

1,Concept of components:

A. Component: A software module that can be used for reuse, release, and deployment.

B. componentized development on the. NET platform is based on an assembly, and an assembly is a component.

C. An important feature of components: interfaces and implementations are separated.

2,Componentized development methods and steps:

A. reuse existing components

B. Develop some new components

C. Combine new and old components to build a new system.

3,Component dependency in componentized development:

A. First compilation is only dependent on others, but not those of others.

B. Avoid circular dependency in large software systems.

[Sense:] in the daily accumulation of code, you should learn to organize and manage code by components, so that the development of applications will naturally be very fast.

Section 3SilverlightProject Structure Analysis

1,SilverlightApplication and host

When Visual Studio is used to create a Silverlight project, an ASP. NET Web Application is associated by default, and a Silverlight project name + TestPage. aspx is used to host the Silverlight page.

2,XapSecrets in the package

A. It is A Zip file.

B. There is an AppMainifest. xaml file, which is called the Silverlight Application List. It specifies the names and types of the assembly and entry assembly.

C. All the XAML pages are embedded as resources in the Assembly.

3,Operating Mechanism:

A. When A user accesses A project that contains the Silverlight page. on the aspx webpage, the browser found a reference ClientBin/Silverlight project name from the received HTML code. the <object> element of the xap, which sends a response to the Web server. the HTTP request of the xap file.

B. After the browser receives the. xap file sent back by the web server, it starts the Silverlight plug-in to provide a runtime environment for the Silverlight application.

C. The Silverlight plug-in is expanded. the content of the xap file, locate and load the Silverlight assembly, and instantiate an App object. The App object constructor extracts the xaml code of the Silverlight page from the Assembly Resource and displays it.

Section 4Interoperability set and local type

 1. NETInteroperability assembly

A. the. NET application uses the interoperability assembly as A bridge to call the COM component. (Indirect call)

B. The interoperability Assembly determines the correspondence between the types in. NET and those in COM components.

C. add a reference to this mutually operated assembly in the. NET project.. NET application to create various types of instances (objects) contained in this Assembly, the methods for these objects will be forwarded to the COM component.

2. NETInteroperability Assembly features:

A. the new features of the local type are actually embedded into the main program of. NET.

B. If the embedded type is extracted from a type called "primary interoperability Assembly" (PIA), the local type is used.. NET applications are separated from the version dependency on COM components.

C. The type of the same name in the interoperability set should be equivalent even if they have different members. This is the local type equivalence supported by. NET4.0.

[Sense:]. NET4.0 has strong support for COM components, so that we can fully call a large number of COM-based applications. For example, in the silverlight program, you can export data to an excel file and print data in the Excel file.

Related Article

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.