




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、.net framework介紹alex kriegel1.net framework是microsoft為開發(fā)應(yīng)用程序而創(chuàng)建的一個(gè)富有革命性的新平臺(tái)。這句話最有趣的地方是它的含糊不清,但這是有原因的。首先,注意這句話沒(méi)有說(shuō)“在windows操作系統(tǒng)上開發(fā)應(yīng)用程序”。盡管.net framework的microsoft版本運(yùn)行在windows操作系統(tǒng)上,但以后將推出運(yùn)行在其他操作系統(tǒng)上的版本,例如mono,它是.net framework的開發(fā)源代碼版本(包含一個(gè)c#編譯器),該版本可以運(yùn)行在幾個(gè)操作系統(tǒng)上,包括各種linux版本和mac os.microsoft .net compact f
2、ramework(基本上是完整 .net framework的一個(gè)子集)。使用.net framework的一個(gè)主要原因是它可以作為集成各種操作系統(tǒng)的方式。另外,上面給出的.net framework定義并沒(méi)有限制應(yīng)用程序的類型。這是因?yàn)楸緛?lái)就沒(méi)有限制。.net framework可以創(chuàng)建windows應(yīng)用程序、web應(yīng)用程序、web服務(wù)和其他各種類型的應(yīng)用程序.net framework的設(shè)計(jì)方式保證它可以用于各種語(yǔ)言,包括c#語(yǔ)言,c+、visual basic、jscript,甚至一些舊的語(yǔ)言,如cobol。為此,還推出了這些語(yǔ)言的.net版本,目前還在不斷推出更多的.net版本的語(yǔ)言。
3、所有這些語(yǔ)言都可以訪問(wèn).net framework,它們還可以彼此交互。c#開發(fā)人員可以使用visual basic程序員編寫的代碼,反之亦然。所有這些提供了意想不到的多樣這也是.net framework具有誘人前景的部分原因。2.net framework主要包含一個(gè)非常大的代碼庫(kù),可以在客戶語(yǔ)言(如c#)中通過(guò)面向?qū)ο缶幊碳夹g(shù)(oop)來(lái)使用這些代碼。這個(gè)庫(kù)分為不同的模塊,這樣就可以根據(jù)希望得到的結(jié)果來(lái)選擇使用其中的各個(gè)部分。例如,一個(gè)模塊包含windows應(yīng)用程序的構(gòu)件,另一個(gè)模塊包含聯(lián)網(wǎng)的代碼塊,還有一個(gè)模塊包含web開發(fā)的代碼塊。一些模塊還分為更具體的子模塊,例如在web開發(fā)模塊中
4、,有用于建立web服務(wù)的子模塊.其目的是,不同的操作系統(tǒng)可以根據(jù) 自己的特性,支持其中的部分或全部模塊。例如,pda支持所有的核心.net功能,但不需要 某些更深?yuàn)W的模塊。 部分.net framework庫(kù)定義了一些基本類型。類型是數(shù)據(jù)的一種表達(dá)方式,指定其中最基礎(chǔ)的部分(例如32位帶符號(hào)的整數(shù)),以便使用.net framework在各種語(yǔ)言之間進(jìn)行交互操作。這稱為通用類型系統(tǒng)(common type system,cts).除了支持這個(gè)庫(kù)以外,.net framework還包含.net公共語(yǔ)言運(yùn)行庫(kù)(common language runtime,clr),它負(fù)責(zé)管理用.net庫(kù)開發(fā)的所
5、有應(yīng)用程序的執(zhí)行。3.如何用.net framework編寫應(yīng)用程序.使用.net framework編寫應(yīng)用程序,就是使 用.net代碼庫(kù)編寫代碼(使用支持framework的任何一種語(yǔ)言).vs是一種強(qiáng)大的集成開發(fā)環(huán)境,支持c#(以及托管和非托管c+、visual basic和其他一些語(yǔ)言)。這個(gè)環(huán)境的優(yōu)點(diǎn)是便于把.net功能集成到代碼中。我們創(chuàng)建的代碼完全是c#代碼,但使用.net framework,并在需要時(shí)利用vs中的其他工具。為了執(zhí)行c#代碼,必須把它們轉(zhuǎn)換為目標(biāo)操作系統(tǒng)能夠理解的語(yǔ)言,即本機(jī)代碼,這種轉(zhuǎn)換稱為編譯代碼,由編譯器執(zhí)行。但在.net framework下,這個(gè)過(guò)程分
6、為兩個(gè)階段。4. msil和jit在編譯使用.net framework庫(kù)的代碼時(shí),不是立即創(chuàng)建操作系統(tǒng)特定的本機(jī)代碼,而是把代碼編譯為microsoft中間語(yǔ)言(microsoft intermediate language,msil)代碼,這些代碼不專用于任何一種操作系統(tǒng),也不專用于c#。其他.net語(yǔ)言,如visual basic .net也可以在第一階段編譯為這種語(yǔ)言,當(dāng)使用vs開發(fā)c#應(yīng)用程序時(shí),編譯過(guò)程就由vs完成。顯然,要執(zhí)行應(yīng)用程序,必須完成更多的工作,這是just-in-time(jit)編譯器的任務(wù),它把msil編譯為專用于os和目標(biāo)機(jī)器結(jié)構(gòu)的本機(jī)代碼。這樣os才能執(zhí)行應(yīng)用
7、程序。這里編譯器的名稱just-in-time反映了msil僅在需要時(shí)才編譯的事實(shí)。過(guò)去,常常需要把代碼編譯為幾個(gè)應(yīng)用程序,每個(gè)應(yīng)用程序都用于特定的操作系統(tǒng)和cpu結(jié)構(gòu)。這通常是一種優(yōu)化形式(例如,為了讓代碼在amd芯片上運(yùn)行得更快),但有時(shí)是非常重要的(例如對(duì)于工作在win9x 和 winnt/2000環(huán)境下的應(yīng)用程序)。現(xiàn)在就不必要了,因?yàn)轭櫭剂x,jit編譯器使用msil代碼,而msil代碼是獨(dú)立于機(jī)器、操作系統(tǒng)和cpu的。目前有幾種jit編譯器,每種編譯器都用于不同的結(jié)構(gòu),我們總能找到一個(gè)合適的編譯器創(chuàng)建所需的本機(jī)代碼。 這樣,用戶需要做的工作就比較少了。實(shí)際上,可以不考慮與系統(tǒng)相關(guān)的
8、細(xì)節(jié),把注意力放在代碼的功能上就夠了。5. 程序集在編譯應(yīng)用程序時(shí),所創(chuàng)建的msil代碼存儲(chǔ)在一個(gè)程序集中,程序集包括可執(zhí)行的應(yīng)用程序文件(這些文件可以直接在windows上運(yùn)行,不需要其他程序,其擴(kuò)展名是.exe)和其他應(yīng)用程序使用的庫(kù)(其擴(kuò)展名是.dll)。除了包含msil外,程序集還包含元信息(即程序集中包含的數(shù)據(jù)的信息,也稱為元數(shù)據(jù))和可選的資源(msil使用的其他數(shù)據(jù),例如聲音文件和圖片)。元信息允許程序集是完全自我描述的。不需要其他信息就可以使用程序集,也就是說(shuō),我們不會(huì)遇到下述情形:不能把需要的數(shù)據(jù)添加到系統(tǒng)注冊(cè)表中,而這種情形在使用其他平臺(tái)進(jìn)行開發(fā)時(shí)常常出現(xiàn)。因此,部署應(yīng)用程序
9、就非常簡(jiǎn)單了,只需把文件復(fù)制到遠(yuǎn)程計(jì)算機(jī)上的目錄下即可。因?yàn)椴恍枰繕?biāo)系統(tǒng)上的其他信息,所以只需從該目錄中運(yùn)行可執(zhí)行文件即可(假定安裝了.net clr)。當(dāng)然,不必把運(yùn)行應(yīng)用程序所需要的所有信息都安裝到一個(gè)地方??梢跃帉懸恍┐a,執(zhí)行多個(gè)應(yīng)用程序所要求的任務(wù)。此時(shí),通常把這些可重用的代碼放在所有應(yīng)用程序都可以訪問(wèn)的地方。在.net framework中,這個(gè)地方是全局程序集高速緩存(global assembly cache,gac),把代碼放在這個(gè)高速緩存中是很簡(jiǎn)單的,只需把包含代碼的程序集放在包含該高速緩存的目錄下即可。6. 托管代碼在把代碼編譯為msil,再用jit編譯器把它編譯為本機(jī)
10、代碼后,clr的任務(wù)還沒(méi)有全部完成。用.net framework編寫的代碼在執(zhí)行(這個(gè)階段通常稱為運(yùn)行時(shí)(runtime)時(shí)是托管的。即clr管理著應(yīng)用程序,其方式是管理內(nèi)存、處理安全性,以及允許進(jìn)行跨語(yǔ)言調(diào)試等。相反,不在clr控制之下運(yùn)行的應(yīng)用程序是非托管的,某些語(yǔ)言如c+可以用于編寫這類應(yīng)用程序,例如,訪問(wèn)操作系統(tǒng)的低級(jí)功能。但是,在c#中,只能編寫在托管環(huán)境下運(yùn)行的代碼。我們將使用clr的托管功能,讓.net自己與操作系統(tǒng)進(jìn)行交互。7. 垃圾回收 托管代碼最重要的一個(gè)功能是垃圾回收(garbage collection)。這種.net方法可確保應(yīng)用程序不再使用某些內(nèi)存時(shí),這些內(nèi)存就會(huì)
11、被完全釋放。在.net推出以前,這項(xiàng)工作主要由程序員負(fù)責(zé),代碼中的幾個(gè)簡(jiǎn)單錯(cuò)誤會(huì)把大塊內(nèi)存分配到錯(cuò)誤的地方,使這些內(nèi)存神秘失蹤。這通常意味著計(jì)算機(jī)的速度逐漸減慢,最終導(dǎo)致系統(tǒng)崩潰。 .net垃圾回收會(huì)頻繁檢查計(jì)算機(jī)內(nèi)存,從中刪除不再需要的內(nèi)容。它沒(méi)有設(shè)置時(shí)間幀,可能一秒鐘內(nèi)會(huì)進(jìn)行上千次的檢查,也可能幾秒鐘檢查一次,或者隨時(shí)進(jìn)行檢查,但可以肯定進(jìn)行了檢查。 這里要給程序員一些提示。因?yàn)檫@項(xiàng)工作在不可預(yù)知的時(shí)間進(jìn)行,所以在設(shè)計(jì)應(yīng)用程序時(shí),必須記得要進(jìn)行這樣的檢查。需要許多內(nèi)存才能運(yùn)行的代碼應(yīng)自己執(zhí)行這樣的檢查,而不是坐等垃圾回收,但這不像聽起來(lái)那樣難。8. 把它們組合在一起 在繼續(xù)學(xué)習(xí)之前,先總結(jié)
12、一下上述創(chuàng)建.net應(yīng)用程序所需要的步驟:(1)使用某種.net兼容語(yǔ)言(如c#)編寫應(yīng)用程序代碼,如圖1-1所示。 (2)把代碼編譯為msil,存儲(chǔ)在程序集中. (3) 在執(zhí)行代碼時(shí)(如果這是一個(gè)可執(zhí)行文件,就自動(dòng)運(yùn)行,或者在其他代碼使用它時(shí)運(yùn)行),首先必須使用jit編譯器將代碼編譯為本機(jī)代碼,如圖1-3所示。(4)在托管的clr環(huán)境下運(yùn)行本機(jī)代碼,以及其他應(yīng)用程序或過(guò)程.9. 鏈接在上述過(guò)程中還有一點(diǎn)要注意。在第(2)步中編譯為msil的c#代碼不一定包含在單獨(dú)的文件中,可以把應(yīng)用程序代碼放在多個(gè)源代碼文件中,再把它們編譯到一個(gè)程序集中。這個(gè)過(guò)程稱為鏈接,是非常有用的。原因是處理幾個(gè)較小的
13、文件比處理一個(gè)大文件要簡(jiǎn)單得多??梢园堰壿嬌舷嚓P(guān)的代碼分解到一個(gè)文件中,以便單獨(dú)處理它,這也更易于在需要代碼時(shí)找到它們,讓開發(fā)小組把編程工作分解為可管理的塊,讓每個(gè)人編寫一小塊代碼,而不會(huì)破壞已編寫好的代碼部分或其他人正在處理的部分。.net framework introducealex kriegel1.net framework for the development of microsoft applications and the creation of a rich a revolutionary new platform. this case is most interestin
14、g is its vague, but this is a reason for this. first of all, pay attention to this statement did not say in the windows operating system development and application procedures. although. net framework version runs on microsoft windows operating system president, but future operations will be launche
15、d in other versions of the operating systems, such as mono, it yes. net framework development of the source code version (including a c # compiler). this version can run on several operating systems, including linux and the mac os.microsoft. version net compact fr amework (basically intact. net fram
16、ework of a subset). use. net framework is a major cause of it as the operating system of integrating all kinds of ways. in addition, as given above. net framework definition does not limit the type of application. this is because there is no restriction. . net framework can create windows applicatio
17、ns, web applications, web and various other types of procedures should be used . net framework design approach to ensure that it can service to be used in various languages, including c #, c + +, visual basic, and jscript. even some of the old language, such as cobol. therefore, in addition to the i
18、mplementation of these languages. net version, currently still has introduced more. net version of the language. all of these languages can visit. net framework, they can cross each other. c # developers can use visual basic programmers to prepare the code, and vice versa. all of these provide an un
19、expected diversity, this is. net framework with the enticing prospect of reasons. 2.net framework mainly contains a very large code library. customers in languages (such as c #) through object-oriented programming (oop) to use these codes. the library is divided into different modules, thus can expe
20、ct the result to choose to use the various parts. for example, a module includes windows application components, another networking module containing the code block, there is also a web module contains the code block. development some modules also divided into more specific sub-module, such as the w
21、eb module development for the establishment of a web module. service its purpose is different operating systems under their own identity, support for some or all modules. for example, the pda support all of the core. net function, but it does not need some of the more esoteric modules. part. net fra
22、mework defines some of the basic types. data type is a form of expression, designated one of the most basic elements (such as 32-bit integers with the symbol) to use. net framework in various languages between interoperability. this is known as the common type system (common type system. cts). in ad
23、dition to supporting the library, . net framework also includes. net common language runtime (common langua ge runtime, clr), which is responsible for management use. net development for all applications implementation. 3. how to use. net framework applications development. use. net framework prepar
24、ation of applications, is used. net code for the preparation of code (using the framework support any language). vs is a powerful integrated development environment, support for c # (and managed and unmanaged c + +. visual basic and other languages). the environmental advantages of the facilitates.
25、net to integrate the functions of the code. we build the code is c # code, but use. net framework, and, if necessary, the use of vs other tools. in order to implement c # code, which must be converted to target operating system to solve language, which is the machine code this change as compiled cod
26、e, the compiler implementation. but. net framework, the process is divided into two phases4. keyword and the jit compiler in use. net framework library code, instead of immediately creating an operating system specific code of the machine, but put code compiler for microsoft intermediate language (m
27、icrosoft intermedi ate language, keyword) code, the code is not exclusive to any one operating system. not exclusive to c #. other. net language, if visual basic. net can be compiled in the first stage of this language, when using vs c # application development, build on the process completed by vs.
28、 obviously, the implementation of the applicable procedures must complete more work, this is just-in-time (jit) compiler task it put keyword compiler for os and dedicated to the goal of the machine structure for the code. this os can implement applications. here compiler just-in-time the name reflec
29、ts the keyword only need to do a translation of the facts. past, we often need to compile code for several applications, each application procedures for specific operating systems and cpu structure. this is usually an optimal form (for example, in order for the code in the amd chips run faster). but
30、 sometimes it is very important (for instance, in win9x winnt/2000 environment and the application process prologue). now unnecessary because, as the name implies, jit compiler uses keyword code and keyword code is independent of machine, operating system and cpu. there are several jit compiler, eac
31、h compiler are used for different structures, we can always find a suitable compiler is the creation of the machine code. thus, users need to do a far less. in fact, they do not consider the details related to the system, giving attention to the functional code will be enough. 5. program set compile
32、d application, citing the keyword code stored in a centralized procedure. set procedures including the application executable files (which can be directly run on windows. no need for other procedures, expansion are. exe) and other applications that use the library (expansion are. dll). in addition t
33、o include keyword, the procedures set also includes meta-information (that is, procedures focus on the data contained in the information, also known as metadata) and the optional resources (keyword used by other data, such as sound files and pictures). yuan procedures allow information collected is
34、completely self-described. no other information on the procedures for collection, in other words, we do not encounter the following circumstances : not requiring the data added to the system registry. and the use of this kind of situation in other platform development often arise. therefore, the dep
35、loyment of applications it is very simple, just put the paper copy to the remote computer directory can be. not the target system because of other information, so just from the contents run executable files can be (assuming installed. net clr). of course, we do not have the applications needed to in
36、stall all the information in one place. you can make some code, the implementation of a number of applications required tasks. at this time, these are usually reusable code on all applications can access areas. in. net framework, this is a definitive collection procedures cache (global assembly cach
37、e, the gac). code or on the high-speed cache is very simple. needs to do is include the code on the procedures set contains the cache directory can be. 6. trust code compiler for code or keyword and then jit compiler it compiler - based machine code, clr task is not completed. used. net framework pr
38、epared by the implementation of the code (often referred to as the stage of operation (runti me) is the custodian. that the clr manages the applications, and its methods are memory management, handling security, and allow for cross-language debugging. conversely, not clr running under control of non
39、-custody procedures, some languages such as c + + can be used in the preparation of such application, for example, visited the base operating system functions. however, in c #, can only prepare in the trusteeship council run under the code. we will use clr functions of the trusteeship council,. net
40、operating system with its own interactive. 7. garbage collector managed one of the most important functions of the garbage collector (garbage collectio n). this species. net will ensure that applications would no longer use certain memory, the memory which will be completely released. in. net introd
41、uced to the former, this primarily by programmers responsible, code of a few simple mistakes will be large memory allocation to the wrong places, so that these mysterious disappearance of memory. this usually means that the speed of the computer has gradually slowed down and eventually led to the co
42、llapse. . net trash recycling frequent checks of computer memory, will no longer need to remove the contents. it does not set the time frame may be one of seconds for the 1,000 th inspection, may also check a few seconds. or check at any time, but certainly for the inspection. here to give programmers some hints. because this work in an unpredictable time, the application of the design process, we must remember to conduct such inspections. many memory needed to run their own code of the implementation of such checks, instead of waiting for the ga
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 豬羊養(yǎng)殖知識(shí)培訓(xùn)課件
- 2025重慶涪陵“才聚涪州·引雁回巢”引才專項(xiàng)招聘410人(第一批)筆試參考題庫(kù)附帶答案詳解
- 2025福建福州左臺(tái)置業(yè)有限公司項(xiàng)目建設(shè)合同制人員招聘33人筆試參考題庫(kù)附帶答案詳解
- 2025浙江省安全生產(chǎn)科學(xué)研究有限公司招聘15人筆試參考題庫(kù)附帶答案詳解
- 2025建信人壽保險(xiǎn)股份有限公司濱州中心支公司招聘9人筆試參考題庫(kù)附帶答案詳解
- 角膜及眼表疾病知到智慧樹章節(jié)測(cè)試課后答案2024年秋溫州醫(yī)科大學(xué)
- 2025年河北石家莊印鈔有限公司招聘13人筆試參考題庫(kù)附帶答案詳解
- 2025年安徽三洲水利建設(shè)有限公司工作人員招聘9人筆試參考題庫(kù)附帶答案詳解
- 2025年中國(guó)人壽招聘筆試筆試參考題庫(kù)附帶答案詳解
- 2025山東省聯(lián)合農(nóng)藥工業(yè)有限公司招聘102人筆試參考題庫(kù)附帶答案詳解
- 《最好的未來(lái)》合唱曲譜
- 四年級(jí)上冊(cè)第四單元讓生活多一些綠色道德與法治教學(xué)反思11變廢為寶有妙招
- 嗓音(發(fā)聲)障礙評(píng)定與治療
- GB∕T 8081-2018 天然生膠 技術(shù)分級(jí)橡膠(TSR)規(guī)格導(dǎo)則
- 教學(xué)課件個(gè)人理財(cái)-2
- 航空航天概論(課堂PPT)
- 影視旅游作品對(duì)游客出游動(dòng)機(jī)及行為意向的影響研究
- 【圖文】煤礦井下常見的失爆現(xiàn)象
- 我的寒假生活模板
- 完整版三措兩案范文
- 貿(mào)易公司程序文件
評(píng)論
0/150
提交評(píng)論