【正文】
操作性,從而使托管代碼可以調(diào)用 COM 組件, COM 組件也可以調(diào)用托管代碼 (見第 29 章 )。 頁(yè)面可以用 編寫,現(xiàn)在可以把 當(dāng)作一種編譯語(yǔ)言來(lái)運(yùn)行,而不是解釋性的語(yǔ) 言,也可以編寫輸入量比較大的 代碼。在 .NET Framework 版本推出之前,用戶必須下載相應(yīng)的軟件,才能使用 J。 C++的一個(gè)有趣的問(wèn)題是在編譯托管代碼時(shí),編譯器可以生成包含內(nèi)嵌本機(jī)可執(zhí)行代碼的 IL。雖然這意味著其中的工作已大大減輕,但用戶仍需要檢查新的 代碼,以確保項(xiàng)目仍可正確工作,因?yàn)檫@種轉(zhuǎn)換并不十分完美。 那么除了 C之外,還有什么語(yǔ)言可以通過(guò) .NET 進(jìn)行交互操作呢?下面就簡(jiǎn)要討論其他常見語(yǔ)言如何與 .NET 交互操作。其原因是編譯過(guò)程的最后一部分是在運(yùn)行時(shí)進(jìn)行的, JIT 編譯器確切地知道程序運(yùn)行在什么類型的處理器上,利用該處理器提供的任何特性或特定的機(jī)器代碼指令來(lái)優(yōu)化最后的可執(zhí)行代碼。也就是說(shuō)編譯為中間語(yǔ)言就可以獲得 .NET 平臺(tái)無(wú)關(guān)性,這與編譯為 Java 字節(jié)代碼就會(huì)得到 Java 平臺(tái)無(wú)關(guān)性是一樣的。 it also facilitates language interoperability. Simply put, you can pile to IL from one language, and this piled code should then be interoperable with code that has been piled to IL from another language. You’re probably now wondering which languages aside from C are interoperable with .NET, so let’s briefly discuss how some of the other mon languages fit into .NET. Visual Basic .NET Visual Basic .NET has undergone a plete revamp from Visual Basic 6 to bring it uptodate with .NET. The way that Visual Basic has evolved over the last few years means that in its previous version, Visual Basic 6, it was not a suitable language for running .NET programs. For example, it is heavily integrated into COM and works by exposing only event handlers as source code to the developer— most of the background code is not available as source code. Not only that, it does not support implementation inheritance, and the standard data types Visual Basic 6 uses are inpatible with .NET. Visual Basic 6 was upgraded to Visual Basic .NET, and the changes that were made to the language are so extensive you might as well regard Visual Basic .NET as a new language. Existing Visual Basic 6 code does not pile as Visual Basic .NET code. Converting a Visual Basic 6 program to Visual Basic .NET requires extensive changes to the code. However, Visual Studio .NET (the upgrade of VS for use with .NET) can do most of the changes for you. If you attempt to read a Visual Basic 6 project into Visual Studio .NET, it will upgrade the project for you, which means that it will rewrite the Visual Basic 6 source code into Visual Basic .NET source code. Although this means that the work involved for you is heavily cut down, you will need to check through the new Visual Basic .NET code to make sure that the project still works as intended because the conversion might not be perfect. One side effect of this language upgrade is that it is no longer possible to pile Visual Basic .NET to native executable code. Visual Basic .NET piles only to IL, just as C does. If you need to continue coding in Visual Basic 6, you may do so, but the executable code produced will pletely ignore the .NET Framework, and you’ll need to keep Visual Stu