Archive for January, 2008

28 CHAPTER 1 THE PHILOSOPHY OF .NET (Web hosting ratings)

Tuesday, January 22nd, 2008

28 CHAPTER 1 THE PHILOSOPHY OF .NET Viewing Type Metadata If you wish to view the type metadata for the currently loaded assembly, press Ctrl+M. Figure 1-8 shows the metadata for the Calc.Add() method. Viewing Assembly Metadata Finally, if you are interested in viewing the contents of the assembly s manifest, simply double-click the MANIFEST icon (see Figure 1-9). Figure 1-8. Viewing type metadata via ildasm.exe Figure 1-9.Double-click here to view the assembly manifest.
Check Tomcat Web Hosting services for best quality webspace to host your web application.

CHAPTER 1 THE PHILOSOPHY OF .NET 27 (Web site domain)

Monday, January 21st, 2008

CHAPTER 1 THE PHILOSOPHY OF .NET 27 Viewing CIL Code In addition to showing the namespaces, types, and members contained in a given assembly, ildasm.exe also allows you to view the CIL instructions for a given member. For example, if you were to doubleclick the Main() method of the CalcApp class, a separate window would display the underlying CIL (see Figure 1-7). Figure 1-6. Your new best friend, ildasm.exe Figure 1-7. Viewing the underlying CIL
Searching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.

26 CHAPTER 1 THE PHILOSOPHY OF .NET (Web server extensions)

Sunday, January 20th, 2008

26 CHAPTER 1 THE PHILOSOPHY OF .NET Depending on the development tool you are using to build your .NET applications, you will have various ways to inform the compiler which assemblies you wish to include during the compilation cycle. You ll examine how to do so in the next chapter, so I ll hold off on the details for now. Using ildasm.exe If you are beginning to feel a tad overwhelmed at the thought of gaining mastery over every namespace in the .NET platform, just remember that what makes a namespace unique is that it contains types that are somehow semantically related. Therefore, if you have no need for a user interface beyond a simple console application, you can forget all about the System.Windows.Forms and System.Web namespaces (among others). If you are building a painting application, the database namespaces are most likely of little concern. Like any new set of prefabricated code, you learn as you go. The Intermediate Language Disassembler utility (ildasm.exe) allows you to load up any .NET assembly and investigate its contents, including the associated manifest, CIL code, and type metadata. By default, ildasm.exe should be installed under C:Program FilesMicrosoft Visual Studio 8SDKv2.0Bin (if you cannot find ildasm.exe in this location, simply search your machine for a file named ildasm.exe ). Once you locate and run this tool, proceed to the File .Open menu command and navigate to an assembly you wish to explore. By way of illustration, here is the CSharpCalculator.exe assembly shown earlier in this chapter (see Figure 1-6). ildasm.exe presents the structure of an assembly using a familiar tree-view format. Figure 1-5. The base class libraries reside in the GAC.
Check Tomcat Web Hosting services for best quality webspace to host your web application.

CHAPTER 1 THE PHILOSOPHY (Web hosting reseller) OF .NET 25

Saturday, January 19th, 2008

CHAPTER 1 THE PHILOSOPHY OF .NET 25 // Explicitly list the namespaces used by this file. using System; using System.Drawing; class MyApp { public void DisplayLogo() { // Create a 20_20 pixel bitmap. Bitmap companyLogo = new Bitmap(20, 20); … } } Because your application is referencing System.Drawing, the compiler is able to resolve the Bitmap class as a member of this namespace. If you did not specify the System.Drawing namespace, you would be issued a compiler error. However, you are free to declare variables using a fully qualified name as well: // Not listing System.Drawing namespace! using System; class MyApp { public void DisplayLogo() { // Using fully qualified name. System.Drawing.Bitmap companyLogo = new System.Drawing.Bitmap(20, 20); … } } While defining a type using the fully qualified name provides greater readability, I think you d agree that the C# using keyword reduces keystrokes. In this text, I will avoid the use of fully qualified names (unless there is a definite ambiguity to be resolved) and opt for the simplified approach of the C# using keyword. However, always remember that this technique is simply a shorthand notation for specifying a type s fully qualified name, and each approach results in the exact same underlying CIL (given the fact that CIL code always makes use of fully qualified names) and has no effect on performance or the size of the assembly. Referencing External Assemblies In addition to specifying a namespace via the C# using keyword, you also need to tell the C# compiler the name of the assembly containing the actual CIL definition for the referenced type. As mentioned, many core .NET namespaces live within mscorlib.dll. However, the System.Drawing. Bitmap type is contained within a separate assembly named System.Drawing.dll. A vast majority of the .NET Framework assemblies are located under a specific directory termed the global assembly cache (GAC). On aWindows machine, this can be located under %windir%Assembly, as shown in Figure 1-5.
Go visit our java server pages services for a reliable, lowcost webhost to satisfy all your needs.

24 CHAPTER 1 THE (Florida web design) PHILOSOPHY OF .NET

Friday, January 18th, 2008

24 CHAPTER 1 THE PHILOSOPHY OF .NET Table 1-4. (Continued) .NET Namespace Meaning in Life System.IO These namespaces include file I/O, buffering, and so forth. As of System.IO.Compression .NET 2.0, the IO namespaces now include support compression System.IO.Ports and port manipulation. System.Net This namespace (as well as other related namespaces) contains types related to network programming (requests/responses, sockets, end points, and so on). System.Reflection These namespaces define types that support runtime type System.Reflection.Emit discovery as well as dynamic creation of types. System.Runtime. This namespace provides facilities to allow .NET types to interact InteropServices with unmanaged code (e.g., C-based DLLs and COM servers) and vice versa. System.Runtime.Remoting This namespace (among others) defines types used to build solutions that incorporate the .NET remoting layer. System.Security Security is an integrated aspect of the .NET universe. In the security-centric namespaces you find numerous types dealing with permissions, cryptography, and so on. System.Threading This namespace defines types used to build multithreaded applications. System.Web A number of namespaces are specifically geared toward the development of .NET web applications, including ASP.NET and XML web services. System.Windows.Forms This namespace contains types that facilitate the construction of traditional desktop GUI applications. System.Xml The XML-centric namespaces contain numerous types used to interact with XML data. Accessing a Namespace Programmatically It is worth reiterating that a namespace is nothing more than a convenient way for us mere humans to logically understand and organize related types. Consider again the System namespace. From your perspective, you can assume that System.Console represents a class named Console that is contained within a namespace called System. However, in the eyes of the .NET runtime, this is not so. The runtime engine only sees a single entity named System.Console. In C#, the using keyword simplifies the process of referencing types defined in a particular namespace. Here is how it works. Let s say you are interested in building a traditional desktop application. The main window renders a bar chart based on some information obtained from a back-end database and displays your company logo. While learning the types each namespace contains takes study and experimentation, here are some obvious candidates to reference in your program: // Here are all the namespaces used to build this application. using System; // General base class library types. using System.Drawing; // Graphical rendering types. using System.Windows.Forms; // GUI widget types. using System.Data; // General data-centric types. using System.Data.SqlClient; // MS SQL Server data access types. Once you have specified some number of namespaces (and set a reference to the assemblies that define them), you are free to create instances of the types they contain. For example, if you are interested in creating an instance of the Bitmap class (defined in the System.Drawing namespace), you can write:
We recommend cheap and reliable webhost to host and run your web applications: Coldfusion Web Hosting services.

Web hosting contract - CHAPTER 1 THE PHILOSOPHY OF .NET 23

Thursday, January 17th, 2008

CHAPTER 1 THE PHILOSOPHY OF .NET 23 ‘ Hello world in VB .NET Imports System Public Module MyApp Sub Main() Console.WriteLine(”Hi from VB .NET”) End Sub End Module // Hello world in Managed Extensions for C++ #include “stdafx.h” using namespace System; int main(array ^args) { Console::WriteLine(L”Hi from managed C++”); return 0; } Notice that each language is making use of the Console class defined in the System namespace. Beyond minor syntactic variations, these three applications look and feel very much alike, both physically and logically. Clearly, your primary goal as a .NET developer is to get to know the wealth of types defined in the (numerous) .NET namespaces. The most fundamental namespace to get your hands around is named System. This namespace provides a core body of types that you will need to leverage time and again as a .NET developer. In fact, you cannot build any sort of functional C# application without at least making a reference to the System namespace. Table 1-4 offers a rundown of some (but certainly not all) of the .NET namespaces. Table 1-4. A Sampling of .NET Namespaces .NET Namespace Meaning in Life System Within System you find numerous useful types dealing with intrinsic data, mathematical computations, random number generation, environment variables, and garbage collection, as well as a number of commonly used exceptions and attributes. System.Collections These namespaces define a number of stock container objects System.Collections.Generic (ArrayList, Queue, and so forth), as well as base types and interfaces that allow you to build customized collections. As of .NET 2.0, the collection types have been extended with generic capabilities. System.Data These namespaces are used for interacting with databases using System.Data.Odbc ADO.NET. System.Data.OracleClient System.Data.OleDb System.Data.SqlClient System.Diagnostics Here, you find numerous types that can be used to programmatically debug and trace your source code. System.Drawing Here, you find numerous types wrapping graphical primitives System.Drawing.Drawing2D such as bitmaps, fonts, and icons, as well as printing capabilities. System.Drawing.Printing Continued
If you are in need for chaep and reliable webhost to host your website, our recommendation is http web server services.

The Assembly/Namespace/Type Distinction (Web hosting uk) Each of us understands the

Wednesday, January 16th, 2008

The Assembly/Namespace/Type Distinction Each of us understands the importance of code libraries. The point of libraries such as MFC, J2EE, and ATL is to give developers a well-defined set of existing code to leverage in their applications. However, the C# language does not come with a language-specific code library. Rather, C# developers leverage the language-neutral .NET libraries. To keep all the types within the base class libraries well organized, the .NET platform makes extensive use of the namespace concept. Simply put, a namespace is a grouping of related types contained in an assembly. For example, the System.IO namespace contains file I/O related types, the System.Data namespace defines basic database types, and so on. It is very important to point out that a single assembly (such as mscorlib.dll) can contain any number of namespaces, each of which can contain any number of types. To clarify, Figure 1-4 shows a screen shot of the Visual Studio 2005 Object Brower utility. This tool allows you to examine the assemblies referenced by your current project, the namespaces within a particular assembly, the types within a given namespace, and the members of a specific type. Note that mscorlib.dll contains many different namespaces, each with its own semantically related types. 22 CHAPTER 1 THE PHILOSOPHY OF .NET Figure 1-4. A single assembly can have any number of namespaces. The key difference between this approach and a language-specific library such as MFC is that any language targeting the .NET runtime makes use of the same namespaces and same types. For example, the following three programs all illustrate the ubiquitous Hello World application, written in C#, VB .NET, and Managed Extensions for C++: // Hello world in C# using System; public class MyApp { static void Main() { Console.WriteLine(”Hi from C#”); } }
If you are looking for affordable and reliable webhost to host and run your business application visit our ftp web hosting services.

CHAPTER 1 (Apache web server tutorial) THE PHILOSOPHY OF .NET 21

Wednesday, January 16th, 2008

CHAPTER 1 THE PHILOSOPHY OF .NET 21 the location of an assembly and finding the requested type within the binary by reading the contained metadata. The CLR then lays out the type in memory, compiles the associated CIL into platform-specific instructions, performs any necessary security checks, and then executes the code in question. In addition to loading your custom assemblies and creating your custom types, the CLR will also interact with the types contained within the .NET base class libraries when required. Although the entire base class library has been broken into a number of discrete assemblies, the key assembly is mscorlib.dll. mscorlib.dll contains a large number of core types that encapsulate a wide variety of common programming tasks as well as the core data types used by all .NET languages. When you build .NET solutions, you automatically have access to this particular assembly. Figure 1-3 illustrates the workflow that takes place between your source code (which is making use of base class library types), a given .NET compiler, and the .NET execution engine. Figure 1-3. mscoree.dll in action
Searching for affordable and reliable webhost to host and run your web applications? Go to our java web server services and you will be pleased.

20 CHAPTER 1 THE PHILOSOPHY OF .NET (Hp web site)

Tuesday, January 15th, 2008

20 CHAPTER 1 THE PHILOSOPHY OF .NET However, if you were to simply make use of unsigned data internally as follows: public class Calc { public int Add(int x, int y) { // As this ulong variable is only used internally, // we are still CLS compliant. ulong temp; … return x + y; } } you have still conformed to the rules of the CLS, and can rest assured that all .NET languages are able to invoke the Add() method. Of course, in addition to Rule 1, the CLS defines numerous other rules. For example, the CLS describes how a given language must represent text strings, how enumerations should be represented internally (the base type used for storage), how to define static members, and so forth. Luckily, you don t have to commit these rules to memory to be a proficient .NET developer. Again, by and large, an intimate understanding of the CTS and CLS specifications is only of interest to tool/compiler builders. Ensuring CLS Compliance As you will see over the course of this book, C# does define a number of programming constructs that are not CLS-compliant. The good news, however, is that you can instruct the C# compiler to check your code for CLS compliance using a single .NET attribute: // Tell the C# compiler to check for CLS compliance. [assembly: System.CLSCompliant(true)] Chapter 12 dives into the details of attribute-based programming. Until then, simply understand that the [CLSCompliant] attribute will instruct the C# compiler to check each and every line of code against the rules of the CLS. If any CLS violations are discovered, you receive a compiler error and a description of the offending code. Understanding the Common Language Runtime In addition to the CTS and CLS specifications, the final TLA (three letter abbreviation) to contend with at the moment is the CLR. Programmatically speaking, the term runtime can be understood as a collection of external services that are required to execute a given compiled unit of code. For example, when developers make use of the Microsoft Foundation Classes (MFC) to create a new application, they are aware that their program requires the MFC runtime library (i.e., mfc42.dll). Other popular languages also have a corresponding runtime. VB6 programmers are also tied to a runtime module or two (e.g., msvbvm60.dll). Java developers are tied to the Java Virtual Machine (JVM) and so forth. The .NET platform offers yet another runtime system. The key difference between the .NET runtime and the various other runtimes I just mentioned is the fact that the .NET runtime provides a single well-defined runtime layer that is shared by all languages and platforms that are .NET-aware. The crux of the CLR is physically represented by a library named mscoree.dll (aka the Common Object Runtime Execution Engine). When an assembly is referenced for use, mscoree.dll is loaded automatically, which in turn loads the required assembly into memory. The runtime engine is responsible for a number of tasks. First and foremost, it is the entity in charge of resolving
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.

CHAPTER 1 THE PHILOSOPHY (Photo web hosting) OF .NET 19

Monday, January 14th, 2008

CHAPTER 1 THE PHILOSOPHY OF .NET 19 Understanding the Common Language Specification As you are aware, different languages express the same programming constructs in unique, languagespecific terms. For example, in C# you denote string concatenation using the plus operator (+), while in VB .NET you typically make use of the ampersand (&). Even when two distinct languages express the same programmatic idiom (e.g., a function with no return value), the chances are very good that the syntax will appear quite different on the surface: ‘ VB .NET method returning nothing. Public Sub MyMethod() ‘ Some interesting code… End Sub // C# method returning nothing. public void MyMethod() { // Some interesting code… } As you have already seen, these minor syntactic variations are inconsequential in the eyes of the .NET runtime, given that the respective compilers (vbc.exe or csc.exe, in this case) emit a similar set of CIL instructions. However, languages can also differ with regard to their overall level of functionality. For example, a .NET language may or may not have a keyword to represent unsigned data, and may or may not support pointer types. Given these possible variations, it would be ideal to have a baseline to which all .NET-aware languages are expected to conform. The Common Language Specification (CLS) is a set of rules that describe in vivid detail the minimal and complete set of features a given .NET-aware compiler must support to produce code that can be hosted by the CLR, while at the same time be accessed in a uniform manner by all languages that target the .NET platform. In many ways, the CLS can be viewed as a subset of the full functionality defined by the CTS. The CLS is ultimately a set of rules that compiler builders must conform to, if they intend their products to function seamlessly within the .NET universe. Each rule is assigned a simple name (e.g., CLS Rule 6 ) and describes how this rule affects those who build the compilers as well as those who (in some way) interact with them. The cr me de la cr me of the CLS is the mighty Rule 1: Rule 1: CLS rules apply only to those parts of a type that are exposed outside the defining assembly. Given this rule, you can (correctly) infer that the remaining rules of the CLS do not apply to the logic used to build the inner workings of a .NET type. The only aspects of a type that must conform to the CLS are the member definitions themselves (i.e., naming conventions, parameters, and return types). The implementation logic for a member may use any number of non-CLS techniques, as the outside world won t know the difference. To illustrate, the following Add() method is not CLS-compliant, as the parameters and return values make use of unsigned data (which is not a requirement of the CLS): public class Calc { // Exposed unsigned data is not CLS compliant! public ulong Add(ulong x, ulong y) { return x + y;} }
Please visit our professional web hosting services to find out about cheap and reliable webhost service that will surely answer all your demands.