計算機外文翻譯---net framework 概述_第1頁
已閱讀1頁,還剩23頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、<p><b>  譯文與原文</b></p><p>  .NET Framework 概述</p><p>  .NET Framework 是支持生成和運行下一代應用程序和 XML Web services 的內部 Windows 組件。.NET Framework 旨在實現下列目標: </p><p>  提供一個一致的面向對

2、象的編程環(huán)境,而無論對象代碼是在本地存儲和執(zhí)行,還是在本地執(zhí)行但在 Internet 上分布,或者是在遠程執(zhí)行的。 </p><p>  提供一個將軟件部署和版本控制沖突最小化的代碼執(zhí)行環(huán)境。 </p><p>  提供一個可提高代碼(包括由未知的或不完全受信任的第三方創(chuàng)建的代碼)執(zhí)行安全性的代碼執(zhí)行環(huán)境。 </p><p>  提供一個可消除腳本環(huán)境或解釋環(huán)境的性

3、能問題的代碼執(zhí)行環(huán)境。 </p><p>  使開發(fā)人員的經驗在面對類型大不相同的應用程序(如基于 Windows 的應用程序和基于 Web 的應用程序)時保持一致。 </p><p>  按照工業(yè)標準生成所有通信,以確?;?.NET Framework 的代碼可與任何其他代碼集成。 </p><p>  .NET Framework 具有兩個主要組件:公共語言運

4、行庫和 .NET Framework 類庫。公共語言運行庫是 .NET Framework 的基礎。您可以將運行庫看作一個在執(zhí)行時管理代碼的代理,它提供內存管理、線程管理和遠程處理等核心服務,并且還強制實施嚴格的類型安全以及可提高安全性和可靠性的其他形式的代碼準確性。事實上,代碼管理的概念是運行庫的基本原則。以運行庫為目標的代碼稱為托管代碼,而不以運行庫為目標的代碼稱為非托管代碼。.NET Framework 的另一個主要組件是類庫,它

5、是一個綜合性的面向對象的可重用類型集合,您可以使用它開發(fā)多種應用程序,這些應用程序包括傳統的命令行或圖形用戶界面 (GUI) 應用程序,也包括基于 ASP.NET 所提供的最新創(chuàng)新的應用程序(如 Web 窗體和 XML Web services)。</p><p>  .NET Framework 可由非托管組件承載,這些組件將公共語言運行庫加載到它們的進程中并啟動托管代碼的執(zhí)行,從而創(chuàng)建一個可以同時利用托管和非

6、托管功能的軟件環(huán)境。.NET Framework 不但提供若干個運行庫宿主,而且還支持第三方運行庫宿主的開發(fā)。</p><p>  例如,ASP.NET 承載運行庫以為托管代碼提供可伸縮的服務器端環(huán)境。ASP.NET 直接使用運行庫以啟用 ASP.NET 應用程序和 XML Web services(本主題稍后將對這兩者進行討論)。</p><p>  Internet Explorer

7、是承載運行庫(以 MIME 類型擴展的形式)的非托管應用程序的一個示例。使用 Internet Explorer 承載運行庫使您能夠在 HTML 文檔中嵌入托管組件或 Windows 窗體控件。以這種方式承載運行庫使得托管移動代碼(類似于 Microsoft® ActiveX® 控件)成為可能,不過它需要只有托管代碼才能提供的重大改進(如不完全受信任的執(zhí)行和獨立的文件存儲)。</p><p>

8、  下面的插圖顯示公共語言運行庫和類庫與應用程序之間以及與整個系統之間的關系。該插圖還顯示托管代碼如何在更大的結構內運行。</p><p>  公共語言運行庫的功能</p><p>  公共語言運行庫管理內存、線程執(zhí)行、代碼執(zhí)行、代碼安全驗證、編譯以及其他系統服務。這些功能是在公共語言運行庫上運行的托管代碼所固有的。</p><p>  至于安全性,取決于包括托管組

9、件的來源(如 Internet、企業(yè)網絡或本地計算機)在內的一些因素,托管組件被賦予不同程度的信任。這意味著即使用在同一活動應用程序中,托管組件既可能能夠執(zhí)行文件訪問操作、注冊表訪問操作或其他須小心使用的功能,也可能不能夠執(zhí)行這些功能。</p><p>  運行庫強制實施代碼訪問安全。例如,用戶可以相信嵌入在 Web 頁中的可執(zhí)行文件能夠在屏幕上播放動畫或唱歌,但不能訪問他們的個人數據、文件系統或網絡。這樣,運行

10、庫的安全性功能就使通過 Internet 部署的合法軟件能夠具有特別豐富的功能。</p><p>  運行庫還通過實現稱為通用類型系統 (CTS) 的嚴格類型驗證和代碼驗證基礎結構來加強代碼可靠性。CTS 確保所有托管代碼都是可以自我描述的。各種 Microsoft 和第三方語言編譯器生成符合 CTS 的托管代碼。這意味著托管代碼可在嚴格實施類型保真和類型安全的同時使用其他托管類型和實例。</p>

11、<p>  此外,運行庫的托管環(huán)境還消除了許多常見的軟件問題。例如,運行庫自動處理對象布局并管理對對象的引用,在不再使用它們時將它們釋放。這種自動內存管理解決了兩個最常見的應用程序錯誤:內存泄漏和無效內存引用。</p><p>  運行庫還提高了開發(fā)人員的工作效率。例如,程序員可以用他們選擇的開發(fā)語言編寫應用程序,卻仍能充分利用其他開發(fā)人員用其他語言編寫的運行庫、類庫和組件。任何選擇以運行庫為目標的編譯

12、器供應商都可以這樣做。以 .NET Framework 為目標的語言編譯器使得用該語言編寫的現有代碼可以使用 .NET Framework 的功能,這大大減輕了現有應用程序的遷移過程的工作負擔。</p><p>  盡管運行庫是為未來的軟件設計的,但是它也支持現在和以前的軟件。托管和非托管代碼之間的互操作性使開發(fā)人員能夠繼續(xù)使用所需的 COM 組件和 DLL。</p><p>  運行庫旨

13、在增強性能。盡管公共語言運行庫提供許多標準運行庫服務,但是它從不解釋托管代碼。一種稱為實時 (JIT) 編譯的功能使所有托管代碼能夠以它在其上執(zhí)行的系統的本機語言運行。同時,內存管理器排除了出現零碎內存的可能性,并增大了內存引用區(qū)域以進一步提高性能。</p><p>  最后,運行庫可由高性能的服務器端應用程序(如 Microsoft® SQL Server? 和 Internet 信息服務 (IIS)

14、)承載。此基礎結構使您在享受支持運行庫宿主的行業(yè)最佳企業(yè)服務器的優(yōu)越性能的同時,能夠使用托管代碼編寫業(yè)務邏輯。</p><p>  ADO.NET 概述</p><p>  ADO.NET 提供對 Microsoft SQL Server 等數據源以及通過 OLE DB 和 XML 公開的數據源的一致訪問。數據共享使用者應用程序可以使用 ADO.NET 來連接到這些數據源,并檢索、操作和更

15、新數據。</p><p>  ADO.NET 有效地從數據操作中將數據訪問分解為多個可以單獨使用或一前一后使用的不連續(xù)組件。ADO.NET 包含用于連接到數據庫、執(zhí)行命令和檢索結果的 .NET Framework 數據提供程序。您可以直接處理檢索到的結果,或將其放入 ADO.NET DataSet 對象,以便與來自多個源的數據或在層之間進行遠程處理的數據組合在一起,以特殊方式向用戶公開。ADO.NET DataS

16、et 對象也可以獨立于 .NET Framework 數據提供程序使用,以管理應用程序本地的數據或源自 XML 的數據。</p><p>  ADO.NET 類在 System.Data.dll 中,并且與 System.Xml.dll 中的 XML 類集成。當編譯使用 System.Data 命名空間的代碼時,請引用 System.Data.dll 和 System.Xml.dll。</p>&l

17、t;p>  XML 和 ADO.NET</p><p>  ADO.NET 借用 XML 的力量來提供對數據的斷開式訪問。ADO.NET 的設計與 .NET Framework 中 XML 類的設計是并進的,它們都是同一個結構的組件。</p><p>  ADO.NET 和 .NET Framework 中的 XML 類集中于 DataSet 對象。無論 DataSet 是文件還是

18、XML 流,它都可以使用來自 XML 源的數據來進行填充。無論 DataSet 中數據的數據源是什么,DataSet 都可以寫為符合萬維網聯合會 (W3C) 的 XML,并且將其架構包含為 XML 架構定義語言 (XSD) 架構。由于 DataSet 固有的序列化格式為 XML,它是在層間移動數據的優(yōu)良媒介,這使 DataSet 成為以遠程方式向 XML Web services 發(fā)送數據和架構上下文以及從 XML Web servic

19、es 接收數據和架構上下文的最佳選擇。</p><p>  ADO.NET 組件</p><p>  設計 ADO.NET 組件的目的是為了從數據操作中分解出數據訪問。ADO.NET 的兩個核心組件會完成此任務:DataSet 和 .NET Framework 數據提供程序,后者是一組包括 Connection、Command、DataReader 和 DataAdapter 對象在內的組

20、件。</p><p>  ADO.NET DataSet 是 ADO.NET 的斷開式結構的核心組件。DataSet 的設計目的很明確:為了實現獨立于任何數據源的數據訪問。因此,它可以用于多種不同的數據源,用于 XML 數據,或用于管理應用程序本地的數據。DataSet 包含一個或多個 DataTable 對象的集合,這些對象由數據行和數據列以及主鍵、外鍵、約束和有關 DataTable 對象中數據的關系信息組成

21、。</p><p>  ADO.NET 結構的另一個核心元素是 .NET Framework 數據提供程序,其組件的設計目的相當明確:為了實現數據操作和對數據的快速、只進、只讀訪問。Connection 對象提供與數據源的連接。Command 對象使您能夠訪問用于返回數據、修改數據、運行存儲過程以及發(fā)送或檢索參數信息的數據庫命令。DataReader 從數據源中提供高性能的數據流。最后,DataAdapter 提

22、供連接 DataSet 對象和數據源的橋梁。DataAdapter 使用 Command 對象在數據源中執(zhí)行 SQL 命令,以便將數據加載到 DataSet 中,并使對 DataSet 中數據的更改與數據源保持一致。</p><p>  可以為任何數據源編寫 .NET Framework 數據提供程序。.NET Framework 提供了四個 .NET Framework 數據提供程序:SQL Server .N

23、ET Framework 數據提供程序、OLE DB .NET Framework 數據提供程序、ODBC .NET Framework 數據提供程序和 Oracle .NET Framework 數據提供程序。</p><p>  在層和客戶端之間對數據進行遠程處理或封送</p><p>  DataSet 的設計使您能夠使用 XML Web services 方便地通過 Web 將數據

24、傳輸到客戶端,并允許您使用 .NET 遠程處理服務在 .NET 組件之間封送數據。您還可以通過這種方式對強類型的 DataSet 進行遠程處理。</p><p>  .NET Framework 數據提供程序</p><p>  .NET Framework 數據提供程序用于連接到數據庫、執(zhí)行命令和檢索結果。您可以直接處理檢索到的結果,或將其放入 ADO.NET DataSet 對象,以便

25、與來自多個源的數據或在層之間進行遠程處理的數據組合在一起,以特殊方式向用戶公開。.NET Framework 數據提供程序在設計上是輕量的,它在數據源和代碼之間創(chuàng)建了一個最小層,以便在不以功能為代價的前提下提高性能。</p><p>  .NET Framework 包括 SQL Server .NET Framework 數據提供程序(用于 Microsoft SQL Server 7.0 版或更高版本)、OL

26、E DB .NET Framework 數據提供程序和 ODBC .NET Framework 數據提供程序。</p><p>  使用 ADO.NET 連接到 SQL Server</p><p>  SQL Server .NET Framework 數據提供程序使用 SqlConnection 對象提供與 Microsoft SQL Server 7.0 版或更高版本的連接。<

27、/p><p>  SQL Server .NET Framework 數據提供程序支持類似于 OLE DB (ADO) 連接字符串格式的連接字符串格式。</p><p><b>  關閉連接</b></p><p>  建議使用完 Connection 后始終將其關閉,以便連接可以返回到池中。這可以使用 Connection 對象的 Close 或

28、 Dispose 方法來實現。不是顯式關閉的連接可能不會添加或返回到池中。例如,如果連接已超出范圍但沒有顯式關閉,則僅當達到最大池大小而該連接仍然有效時,該連接才會返回到連接池中。</p><p>  注意不要在類的 Finalize 方法中對 Connection、DataReader 或任何其他托管對象調用 Close 或 Dispose。在終結器中,僅釋放類直接擁有的非托管資源。如果類不擁有任何非托管資源,

29、則不要在類定義中包含 Finalize 方法。</p><p>  集成安全性和 ASP.NET</p><p>  SQL Server 集成安全性(也稱為受信任的連接)在連接到 SQL Server 時可以提供保護,因為它不會在連接字符串中公開用戶標識和密碼。建議使用該方法對連接進行身份驗證。集成安全性使用正在執(zhí)行的進程的當前安全標識或標記。對于桌面應用程序,安全標識或標記通常是當前登

30、錄的用戶的標識。</p><p>  ASP.NET 應用程序的安全標識可設置為幾個不同的選項之一。</p><p>  執(zhí)行數據庫操作和修改數據</p><p>  使用 .NET Framework 數據提供程序,您可以執(zhí)行存儲過程或數據定義語言 (DDL) 語句(如 CREATE TABLE 和 ALTER COLUMN)來對數據庫或目錄執(zhí)行架構操作。這些命令

31、不會像查詢一樣返回行,因此 Command 對象提供了 ExecuteNonQuery 方法來處理這些命令。</p><p>  除了使用 ExecuteNonQuery 來修改架構之外,還可以使用此方法處理那些修改數據但不返回行的 SQL 語句,如 INSERT、UPDATE 和 DELETE。</p><p>  雖然行不是由 ExecuteNonQuery 方法返回的,但可以通過 C

32、ommand 對象的 Parameters 集合來傳遞和返回輸入及輸出參數和返回值。</p><p>  ASP.NET 介紹</p><p>  ASP.NET 不僅僅是 Active Server Page (ASP) 的下一個版本;它還提供了一個統一的 Web 開發(fā)模型,其中包括開發(fā)人員生成企業(yè)級 Web 應用程序所需的各種服務。ASP.NET 的語法在很大程度上與 ASP 兼容,同

33、時它還提供一種新的編程模型和結構,可生成伸縮性和穩(wěn)定性更好的應用程序,并提供更好的安全保護??梢酝ㄟ^在現有 ASP 應用程序中逐漸添加 ASP.NET 功能,隨時增強 ASP 應用程序的功能。</p><p>  ASP.NET 是一個已編譯的、基于 .NET 的環(huán)境,可以用任何與 .NET 兼容的語言(包括 Visual Basic .NET、C# 和 JScript .NET.)創(chuàng)作應用程序。另外,任何 AS

34、P.NET 應用程序都可以使用整個 .NET Framework。開發(fā)人員可以方便地獲得這些技術的優(yōu)點,其中包括托管的公共語言運行庫環(huán)境、類型安全、繼承等等。</p><p>  ASP.NET 可以無縫地與 WYSIWYG HTML 編輯器和其他編程工具(包括 Microsoft Visual Studio .NET)一起工作。這不僅使得 Web 開發(fā)更加方便,而且還能提供這些工具必須提供的所有優(yōu)點,包括開發(fā)人

35、員可以用來將服務器控件拖放到 Web 頁的 GUI 和完全集成的調試支持。</p><p>  當創(chuàng)建 ASP.NET 應用程序時,開發(fā)人員可以使用 Web 窗體或 XML Web services,或以他們認為合適的任何方式進行組合。每個功能都能得到同一結構的支持,使您能夠使用身份驗證方案,緩存經常使用的數據,或者對應用程序的配置進行自定義,這里只是列出幾種可能性而已。 </p><p>

36、;  使用 Web 窗體可以生成功能強大的基于窗體的 Web 頁。生成這些頁時,可以使用 ASP.NET 服務器控件來創(chuàng)建公共 UI 元素,以及對它們進行編程以用于執(zhí)行常見的任務。這些控件使您能夠用可重復使用的內置或自定義組件生成 Web 窗體,從而簡化頁面的代碼。</p><p>  XML Web services 提供了遠程訪問服務器功能的途徑。使用 XML Web services,企業(yè)可以公開數據或業(yè)務

37、邏輯的編程接口,而客戶端和服務器應用程序則可以獲取和操作這些編程接口。通過使用諸如 HTTP 和 XML 消息傳遞之類的標準跨越防火墻移動數據,XML Web services 可在客戶端-服務器或服務器-服務器方案下實現數據的交換。XML Web services 不用依靠特定的組件技術或對象調用約定。因此,用任何語言編寫、使用任何組件模型并在任何操作系統上運行的程序,都可以訪問 XML Web services。</p>

38、<p>  這些模型中的每一個模型都可以充分利用所有 ASP.NET 功能,以及 .NET Framework 和 .NET Framework 公共語言運行庫的強大功能。這些功能以及使用它們的方法概述如下: </p><p>  如果您具有 ASP 開發(fā)技能,則新的 ASP.NET 編程模型對您來說將會是非常熟悉的。不過,與 ASP 相比,ASP.NET 對象模型變化顯著,它更為結構化并且面向對象

39、。但這也意味著 ASP.NET 不是完全向后兼容的;幾乎所有現有的 ASP 頁都必須經過一定程度的修改后才可以在 ASP.NET 下運行。此外,對 Visual Basic .NET 的一些主要更改也意味著,用 Visual Basic Scripting 版本編寫的現有 ASP 頁通常將不會直接移植到 ASP.NET 中。不過,在大多數情況下,只需對少數幾行代碼進行必要的修改。</p><p>  從 ASP.

40、NET 應用程序訪問數據庫是向 Web 站點訪問者顯示數據的常用技術。ASP.NET 使得為此目的而對數據庫的訪問比以往更加方便。它還使您能夠從您的代碼管理數據庫。</p><p>  ASP.NET 提供一種簡單的模型,該模型使 Web 開發(fā)人員能夠編寫在應用程序級運行的邏輯。開發(fā)人員可以在 Global.asax 文本文件中或在作為程序集部署的已編譯類中編寫這種代碼。這種邏輯可以包括應用程序級事件,但開發(fā)人員

41、可以輕松地擴展這種模型,以適應他們的 Web 應用程序的需要。</p><p>  ASP.NET 提供易用的應用程序和會話狀態(tài)功能,它們對于 ASP 開發(fā)人員來說是熟悉的,且容易與所有其他 .NET Framework API 兼容。</p><p>  對于需要使用像 ISAPI 編程接口(隨附于以前的 ASP 版本中)那樣功能強大的 API 的高級開發(fā)人員,ASP.NET 提供了 I

42、HttpHandler 和 IHttpModule 接口。實現 IHttpHandler 接口,給您提供了一種與 IIS Web 服務器的低級別請求和響應服務交互的手段,并提供與 ISAPI 擴展非常類似的功能,但編程模型卻較為簡單。實現 IHttpModule 接口使您可以包含參與對應用程序發(fā)出的每個請求的自定義事件。</p><p>  ASP.NET 利用 .NET Framework 和公共語言運行庫中的

43、性能增強功能。另外,它還可以提供相對于 ASP 和其他 Web 開發(fā)平臺來說顯著的性能改進。所有 ASP.NET 代碼都是編譯的,而不是解釋的,這就允許對本機代碼采用早期綁定,強類型處理,以及實時 (JIT) 編譯,這里只列舉幾個優(yōu)點而已。ASP.NET 還可方便地分解,即開發(fā)人員可以移除那些與他們開發(fā)的應用程序不相關的模塊(例如,會話模塊)。ASP.NET 還提供豐富的緩存服務(包括內置服務和緩存 API 兩種)。ASP.NET 還提

44、供性能計數器,開發(fā)人員和系統管理員可以監(jiān)視這些性能計數器,以測試新的應用程序和搜集有關現有應用程序的度量標準。</p><p>  在 Web 頁中編寫自定義調試語句,對排除應用程序代碼中的錯誤非常有幫助。但是,如果不移除它們,則會帶來麻煩。問題是,在應用程序準備好移植到生產服務器時從頁面中移除調試語句,會需要很大的工作量。ASP.NET 提供 TraceContext 類,在開發(fā)頁面時該類用于在頁面上編寫自定義

45、調試語句。只有當您已經對頁面或整個應用程序啟用跟蹤時它們才出現。啟用跟蹤還將有關請求的細節(jié)追加到頁面,或者,追加到存儲在應用程序根目錄中的自定義跟蹤查看器(如果這樣指定的話)。</p><p>  .NET Framework 和 ASP.NET 為 Web 應用程序提供默認授權和驗證方案。可以方便地移除、添加或者替換這些方案,這取決于應用程序的需要。</p><p>  ASP.NET

46、配置設置存儲在基于 XML 的文件中,這些文件都是人可讀和可寫的。每一個應用程序都可以有不同的配置文件,可以擴展配置方案,以適應您的要求。</p><p>  當應用程序安裝在同一臺計算機上,但使用不同的 .NET Framework 版本時,就說應用程序是并行運行的。</p><p>  IIS 6.0 使用一個稱為輔助進程隔離模式的新進程模型,它不同于 IIS 早期版本中使用的進程模型

47、。當在 Windows Server 2003 上運行時,默認情況下 ASP.NET 使用該進程模型。</p><p><b>  維護控件中的狀態(tài)</b></p><p>  ASP.NET 服務器控件從 Control 繼承名為 ViewState 的屬性,這使它可以很容易地加入狀態(tài)管理。ViewState 的類型是 System.Web.UI.StateBag,

48、它是存儲名稱/值對的字典。ASP.NET 頁框架將 ViewState 存留到一個字符串變量,將它發(fā)送到客戶端并作為隱藏變量返回。在回發(fā)時,頁框架分析來自隱藏變量的輸入字符串并填充每一控件的 ViewState 屬性。如果一個控件將 ViewState 用作屬性數據而不是專有字段,則在到客戶端的往返過程期間將自動存留該屬性。(如果屬性未存留在 ViewState 中,則回發(fā)時返回其默認值是切實可行的。)</p><p

49、>  以下代碼段說明在 ViewState 中保存的屬性。</p><p><b>  [C#]</b></p><p>  public String Text {</p><p><b>  get {</b></p><p>  return (String) ViewState[&qu

50、ot;Text"];</p><p><b>  }</b></p><p><b>  set {</b></p><p>  ViewState["Text"] = value;</p><p><b>  }</b></p>&

51、lt;p><b>  }</b></p><p>  可被存留在 ViewState 中的類型</p><p>  如果一個類型是可序列化的或具有為其定義的 TypeConverter,則該類型可以存留在 ViewState 中。但是,與具有 TypeConverter 的那些類型相比,只可序列化的類型不但更慢而且生成大得多的 ViewState。使用為基元類型

52、以及為 String、ArrayList 和 Hashtable 優(yōu)化的有限對象序列化格式,對 ViewState 進行序列化。</p><p>  ViewState 和性能</p><p>  控件開發(fā)人員應該知道,ViewState 中的任何數據自動生成到客戶端的往返過程。因為往返過程影響性能開銷,所以明智的使用 ViewState 是十分重要的。如果有若干依賴通用數據的屬性,則可以

53、通過只將關鍵元素存留到 ViewState 來優(yōu)化性能??丶?Control 繼承名為 EnableViewState 的屬性,該屬性允許控件的使用者啟用或禁用其 ViewState 的持久性。</p><p>  使用 ViewState 自定義狀態(tài)還原</p><p>  為了提高效率,或者為了保存默認情況下不能在 ViewState 中存儲的自定義類型,控件可以自定義在 ViewS

54、tate 中存儲屬性數據的方式。如果控件自定義屬性數據的存儲,則該控件必須還提供為從 ViewState 中存儲的數據還原屬性值提供自定義實現?;?Control 為此目的提供兩個方法:SaveViewState 和 LoadViewState。這些方法具有以下簽名。</p><p><b>  [C#]</b></p><p>  protected virtua

55、l object SaveViewState();</p><p>  protected virtual void LoadViewState(object savedState);</p><p>  Overview of the .NET Framework</p><p>  The .NET Framework is an integral Window

56、s component that supports building and running the next generation of applications and XML Web services. The .NET Framework is designed to fulfill the following objectives: </p><p>  To provide a consistent

57、object-oriented programming environment whether object code is stored and executed locally, executed locally but Internet-distributed, or executed remotely. </p><p>  To provide a code-execution environment

58、that minimizes software deployment and versioning conflicts. </p><p>  To provide a code-execution environment that promotes safe execution of code, including code created by an unknown or semi-trusted third

59、 party. </p><p>  To provide a code-execution environment that eliminates the performance problems of scripted or interpreted environments. </p><p>  To make the developer experience consistent

60、across widely varying types of applications, such as Windows-based applications and Web-based applications. </p><p>  To build all communication on industry standards to ensure that code based on the .NET Fr

61、amework can integrate with any other code. </p><p>  The .NET Framework has two main components: the common language runtime and the .NET Framework class library. The common language runtime is the foundatio

62、n of the .NET Framework. You can think of the runtime as an agent that manages code at execution time, providing core services such as memory management, thread management, and remoting, while also enforcing strict type

63、safety and other forms of code accuracy that promote security and robustness. In fact, the concept of code management is a fun</p><p>  The .NET Framework can be hosted by unmanaged components that load the

64、common language runtime into their processes and initiate the execution of managed code, thereby creating a software environment that can exploit both managed and unmanaged features. The .NET Framework not only provides

65、several runtime hosts, but also supports the development of third-party runtime hosts.</p><p>  For example, ASP.NET hosts the runtime to provide a scalable, server-side environment for managed code. ASP.NET

66、 works directly with the runtime to enable ASP.NET applications and XML Web services, both of which are discussed later in this topic.</p><p>  Internet Explorer is an example of an unmanaged application tha

67、t hosts the runtime (in the form of a MIME type extension). Using Internet Explorer to host the runtime enables you to embed managed components or Windows Forms controls in HTML documents. Hosting the runtime in this way

68、 makes managed mobile code (similar to Microsoft® ActiveX® controls) possible, but with significant improvements that only managed code can offer, such as semi-trusted execution and isolated file storage.</p

69、><p>  The following illustration shows the relationship of the common language runtime and the class library to your applications and to the overall system. The illustration also shows how managed code operate

70、s within a larger architecture.</p><p>  Features of the Common Language Runtime</p><p>  The common language runtime manages memory, thread execution, code execution, code safety verification,

71、compilation, and other system services. These features are intrinsic to the managed code that runs on the common language runtime.</p><p>  With regards to security, managed components are awarded varying de

72、grees of trust, depending on a number of factors that include their origin (such as the Internet, enterprise network, or local computer). This means that a managed component might or might not be able to perform file-acc

73、ess operations, registry-access operations, or other sensitive functions, even if it is being used in the same active application.</p><p>  The runtime enforces code access security. For example, users can t

74、rust that an executable embedded in a Web page can play an animation on screen or sing a song, but cannot access their personal data, file system, or network. The security features of the runtime thus enable legitimate I

75、nternet-deployed software to be exceptionally feature rich.</p><p>  The runtime also enforces code robustness by implementing a strict type-and-code-verification infrastructure called the common type system

76、 (CTS). The CTS ensures that all managed code is self-describing. The various Microsoft and third-party language compilers generate managed code that conforms to the CTS. This means that managed code can consume other ma

77、naged types and instances, while strictly enforcing type fidelity and type safety.</p><p>  In addition, the managed environment of the runtime eliminates many common software issues. For example, the runtim

78、e automatically handles object layout and manages references to objects, releasing them when they are no longer being used. This automatic memory management resolves the two most common application errors, memory leaks a

79、nd invalid memory references.</p><p>  The runtime also accelerates developer productivity. For example, programmers can write applications in their development language of choice, yet take full advantage of

80、 the runtime, the class library, and components written in other languages by other developers. Any compiler vendor who chooses to target the runtime can do so. Language compilers that target the .NET Framework make the

81、features of the .NET Framework available to existing code written in that language, greatly easing the migration</p><p>  While the runtime is designed for the software of the future, it also supports softwa

82、re of today and yesterday. Interoperability between managed and unmanaged code enables developers to continue to use necessary COM components and DLLs.</p><p>  The runtime is designed to enhance performance

83、. Although the common language runtime provides many standard runtime services, managed code is never interpreted. A feature called just-in-time (JIT) compiling enables all managed code to run in the native machine langu

84、age of the system on which it is executing. Meanwhile, the memory manager removes the possibilities of fragmented memory and increases memory locality-of-reference to further increase performance.</p><p>  F

85、inally, the runtime can be hosted by high-performance, server-side applications, such as Microsoft® SQL Server? and Internet Information Services (IIS). This infrastructure enables you to use managed code to write y

86、our business logic, while still enjoying the superior performance of the industry's best enterprise servers that support runtime hosting.</p><p>  Overview of ADO.NET</p><p>  ADO.NET provid

87、es consistent access to data sources such as Microsoft SQL Server, as well as data sources exposed through OLE DB and XML. Data-sharing consumer applications can use ADO.NET to connect to these data sources and retrieve,

88、 manipulate, and update data.</p><p>  ADO.NET cleanly factors data access from data manipulation into discrete components that can be used separately or in tandem. ADO.NET includes .NET Framework data provi

89、ders for connecting to a database, executing commands, and retrieving results. Those results are either processed directly, or placed in an ADO.NET DataSet object in order to be exposed to the user in an ad-hoc manner, c

90、ombined with data from multiple sources, or remoted between tiers. The ADO.NET DataSet object can also be used i</p><p>  The ADO.NET classes are found in System.Data.dll, and are integrated with the XML cla

91、sses found in System.Xml.dll. When compiling code that uses the System.Data namespace, reference both System.Data.dll and System.Xml.dll.</p><p>  XML and ADO.NET</p><p>  ADO.NET leverages the

92、power of XML to provide disconnected access to data. ADO.NET was designed hand-in-hand with the XML classes in the .NET Framework — both are components of a single architecture.</p><p>  ADO.NET and the XML

93、classes in the .NET Framework converge in the DataSet object. The DataSet can be populated with data from an XML source, whether it is a file or an XML stream. The DataSet can be written as World Wide Web Consortium (W3C

94、) compliant XML, including its schema as XML Schema definition language (XSD) schema, regardless of the source of the data in the DataSet. Because the native serialization format of the DataSet is XML, it is an excellent

95、 medium for moving data between tiers ma</p><p>  ADO.NET Components</p><p>  The ADO.NET components have been designed to factor data access from data manipulation. There are two central compon

96、ents of ADO.NET that accomplish this: the DataSet, and the .NET Framework data provider, which is a set of components including the Connection, Command, DataReader, and DataAdapter objects.</p><p>  The ADO.

97、NET DataSet is the core component of the disconnected architecture of ADO.NET. The DataSet is explicitly designed for data access independent of any data source. As a result it can be used with multiple and differing dat

98、a sources, used with XML data, or used to manage data local to the application. The DataSet contains a collection of one or more DataTable objects made up of rows and columns of data, as well as primary key, foreign key,

99、 constraint, and relation information about the data</p><p>  The other core element of the ADO.NET architecture is the .NET Framework data provider, whose components are explicitly designed for data manipul

100、ation and fast, forward-only, read-only access to data. The Connection object provides connectivity to a data source. The Command object enables access to database commands to return data, modify data, run stored procedu

101、res, and send or retrieve parameter information. The DataReader provides a high-performance stream of data from the data source. Finall</p><p>  You can write .NET Framework data providers for any data sourc

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 眾賞文庫僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論