1. Introduction 1.1 What is .NET? 1.2 .NET is just a new name for Windows DNA? 1.3 .NET applies only to establish a web site? 1.4. When did you announce? What will I be released at 1.5 .NET? 1.6 How to develop .Net Application 1.7 Where can I download .NET SDK and Visual Studio 7? What is the key technologies in .NET? 1.9 .NET framework will run on what platform? 1.10 .NET framework support? 1.11 .NET framework meets standardization trends? 2. Basic term 2.1 What is CLR? 2.2 What is CTS? 2.3 What is CLS? 2.4 What is IL? 2.5 What is C #? 2.6 What is the meaning of "managed" in .NET category. 2.7 What is an image? 3. Component 3.1 What is component? 3.2 How to create components? 3.3 What is the difference between private components and shared components? 3.4 How does the component find each other? 3.5 How does the component version work? 4. Application Domain 4.1 What is the application domain? 4.2 How to create AppDomain? 4.3 Can I write my own .NET host? 5. Garbage collection 5.1 What is garbage collection? 5.2 After the last reference to the object is canceled, it does not necessarily be destroyed immediately, right? 5.3 Why doesn't you provide a sectative destructure? 5.4 Is there a problem with the lack of determination in .NET? 5.5 Determination of destructure affects the use of COM objects in managed code? 5.6 I have heard that I should avoid using the Finalize method, then should I achieve Finalize in my class? 5.7 Do I have a means of controlling garbage collection algorithms? 5.8 How do I know what the garbage collector is doing? 6. Attribute 6.1 What is the property? 6.2 Can I create my own metadata properties? 6.3 Can I create my own context attribute? 7. Code Access Security 7.1 What is Code Access Security (CAS)? 7.2 How does Cas work? 7.3 Who defines the CAS code group? 7.4 How to define your own code group? 7.5 How to change the authority set of code group? 7.6 Can I create my own permissions? 7.7 How do you diagnose your own procedure when there is a problem? 7.8 I can't stand the trouble brought by CAS, can I turn off it? 8. Intermediate Language (IL) 8.1 Can I see the middle language of the component? 8.2 Can I get the source code from IL by reverse engineering? 8.3 How to prevent someone from get my code through the reverse engineering? 8.4 Can I use IL to program directly? 8.5 IL can do something you can't do in C #? 9. Did the COM 9.1 COM die? Did the DCOM died? 9.3 MTS / COM done? 9.4 Can I use COM components in .NET? 9.5 Can you use the .NET component in COM? 9.6 Is ATL in the world of .NET? 10. How does the remote calculation of. NET? 10.2 How to get Win32 API in .NET?
11. Class library 11.1 file I / O 11.1.1 How to read text files? 11.1.2 How to write a text file? 11.1.3 How to read a binary? 11.1.4 How to delete a file? 11.2 Text Process 11.2.1 Does the regular expression are supported? 11.3 Internet 11.3.1 How to download the web? 11.3.2 How to use proxy servers (Proxy)? 11.4 XML 11.4.1 Does DOM? 11.4.2 Do you support SAX? 11.4.3 Do you support xpath? 11.5 Thread 11.5.1 Do you support multithreading? 11.5.2 How to generate a thread? 11.5.3 How to stop a thread? 11.5.4 How to use a thread pool? 11.5.5 How do I know when my thread pool work project is completed? 11.5.6 How to prevent concurrent access to the data? 11.6 Tracking 11.6.1 Is there a built-in tracking / log support? 11.6.2 Can I redirect the tracking output to a file? 11.6.3 Can you customize the output of tracking? 12. Resources 12.1 Where can I get details about .NET? 12.2 Sample Code and Utilities 1. Introduction 1.1 What is .NET? It's hard to use a sentence. According to Microsoft, .NET is a "revolutionary new platform, built on open Internet protocols and standards, combining calculations and communications together with a new way through tools and services." More practical definitions are: .NET is a new environment for developing and running software, making it easy to develop web-based services, have rich runtime services to support components written in multiple programming languages, have a cross-language and cross-platform Interoperability. Note that when the term ".NET" is used herein, it refers only the new .NET runtime and related technologies. Sometimes we also call it ".NET framework." This article does not include any other Microsoft to add any existing products and techniques (such as SQL Server.Net) that add .NET names. 1.2 .NET is just a new name for Windows DNA? Do not. In many places, Windows DNA merely refers to the market terminology of a way to use the prior art (that is, the so-called three-order path). .NET is more urgent and includes a complete software development and runtime framework. 1.3 .NET applies only to establish a web site? Do not. If you write any Windows software (using ATL / COM, MFC, VB or even Win32 bare interface), Net may provide a feasible selection (or supplement) for what you are doing. Of course, if you are developing a web site, .NET has many things that make you interested - not just asp . 1.4. When did you announce? On the Forum 2000 Forum held on 22 June 22, 2000, Bill Gates made a speech and taught the "foreground" of .NET. PDC meetings in July 2000 made a lot of talks on .NET technology, the talk representative got the CD which contains the .NET Framework / SDK and Visual Studio 7 preview. What will I be released at 1.5 .NET? It is expected to be in the second half of 2001. 1.6 How to develop .NET applications? The .NET Framework SDK contains a command line compiler and utility that can be used to create .NET applications.
The next version of Visual Studio (called Visual Studio 7 or Visual Studio.net) will fully integrate support for .NET development. 1.7 Where can I download .NET SDK and VISUAL STUDIO 7? From http://msdn.microsoft.com/net, you can download the SDK's Beta 1. If you are a MSDN Universal subscriber, you can also download the Beta 1 version of Visual Studio 7. What is the key technologies in .NET? ASP.NET, CLR (Common Language Runtime-General Language Runture), C # (New Generation Class-Java Language), SOAP, XML, ADO.NET, Multi-Language Support (Eiffel, Cobol, etc.) 1.9 .NET Framework What platform is running? Beta 1 supports development on Windows 2000, NT4 SP6A, Windows ME, and Windows 98. Windows 95 supports runners. Microsoft will publish a new version of Windows as a schedule similar to the .NET run library. Its code is "WHistler", which is largely an expansion update of Windows 2000, which has important changes to GUI. Microsoft will be ".NET-enabled" as a new operating system's selling point, but it seems to be tied together with the .NET run library. If .NET runs can be completed in time, it will be included within the Whistler; otherwise, Whistler will ship separately. 1.10 .NET framework support? Start Microsoft will provide C #, C , VB, and JScript compilers. Other suppliers announced they intentionally develop .NET compilers like Cobol, Eiffel, Perl, SmallTalk, and Python. 1.11 .NET framework meets standardization trends? C # and recommendations for some things called "Universal Language Infrastructure" have been submitted to ECMA. See http://msdn.microsoft.com/net/ecma/ 2. Basic term 2.1 What is CLR? CLR = Common Language Runtime-General Language Runture. The CLR is a set of standard resource collections, regardless of the programming language, all (theoretical) .NET programs can benefit from it. Robert Schmidt (Microsoft) lists the following CLR resources in his MSDN PDC # article: Object-oriented programming model (inheritance, polymorphism, abnormal processing, garbage collection) security model type system all .NET basic class Framework development, debugging and assessment tools and code management IL-machine language converter and optimizer These meaning are, in the .NET world, different programming languages will be more equivalent to the past, although obvious Not all languages support all CLR services. 2.2 What is CTS? CTS = CommON Type System-General Type System. It refers to a series of types that the .NET runtime is understood and then the .NET application can use. However, beware that not all .NET languages will support all types in the CTS. CTS is a super-collection of CLS. 2.3 What is CLS? CLS = Common Language Specification - General Language Specification. It is a subset of a CTS that is expected to support all .NET languages. This idea is to let any programs that use the CLS-compatible type and the .NET program written in any language can be operated. It is theoretically to allow close interoperability between different .NET languages - for example, allowing a C # class to be inherited from one VB class.
2.4 What is IL? IL = intermediate language language - intermediate language. Also known as MSIL. All .NET source code (using any language) is compiled into IL. The IL is then converted to a machine code in the installation point of the software. 2.5 What is C #? C # is a new language running in the .NET framework. In their "C # Introduction" white paper, Microsoft describes C #: "C # is a simple, object-oriented, and is a type of safe, modern programming language. C # (pronunciation is' c sharp" in C and C ') Firmly root into the tree in C and C , will soon be familiar with C and C programmers. C # help developers combine the high productivity of Visual Basic and C direct control capabilities. " "C #" is replaced with "java", you will find this statement is still correct :). If you are a C programmer, you may want to see my C # FAQ. 2.6 What is the meaning of "managed" in .NET category. The term "managed" has led to a lot of misunderstandings. It uses it in different places in .NET, it refers to different things that are different from each other. Managed Code: The .NET Framework provides several core running services to running procedures, such as exception handling and security. In order for these services to work, the code must provide some information about the lowest level of runtime. Such code is called managed code. By default, all C #, Visual Basic.Net and JScript.net code are managed. If it is not specified, the VS7 C code is not managed, but can generate the compiler to generate the managed code through a command line switch (/ COM ). Managed data: refers to data assigned and recycled by the garbage collector of the .NET run. C #, VB.NET and JScript.net data are always managed. Even if the / COM switch is used, the VS7 C data is not managed by default, but it can be specified as managed data using the __gc keyword. Manage class: usually involved in the C Managed Extensions (ME) category. When using ME C , you can specify it as managed by the __gc keyword. The name is actually, the memory occupied by the instance of this class is managed by garbage collector, but not so. This class has become a full .NET group member, which brings benefits and restrictions. One of the benefits is to obtain interoperability between classes written in other languages - for example, an administrative C class can inherit the VB class. One of the limits is that the management class can only inherit a base class. 2.7 What is an image? All .NET compilers produce special data defined in the modules they generated. These special data are encapsulated with modules (subsequent modules are encapsulated into components), and can be accessed by mechanisms called images. The System.Reflection namespace contains classes that ask the module or components to ask them. Using the image to access the special data of .NET. Nothing to access the type library data used in the COM using iTyPelib / ITYPEINFO, and the purpose of use is similar -, for example, determine the data type size, to schedule between the context, process, the boundary between the machine they. The image can also be used to dynamically call the method (see System.Type.InvokeMember), even dynamically create a type (see System.Reflection.Emit.Typebuilder) even during runtime (see System.Reflection.Emit.Typebuilder).
3. Component 3.1 What is component? Components are sometimes described as a logically .exe or .dll, it can be any application (with a primary entry point) or library. A component consists of one or more files (DLL, EXE, HTML files, etc.) indicating a set of resources, type definitions, and these types of implementations. One element can also include references to other components. These resources, types, and references are described in a data block called a list. The list is part of the component, so that components are described herein. An important aspect of components makes them part of a type of unique logo. The unique marker of the type is got together with the components and type names thereof. This means, for example, if the element A outputs a type called T, the component B outputs a type also known as T, and the .NET runtime will be considered a completely different types. In addition, don't confuse the components and namespaces - namespace is just a hierarchical approach to the organization type name. For running libraries, the type name is the type name, whether or not the name. From the running library, it is the only type of the type name (regardless of the type name belonging to which name space). The components are also important in the security of .NET - Many security limits are implemented on the boundary of the component. Finally, the component is the version controlled in .NET - see below for details. 3.2 How to create components? The easiest way to create components is to use the .NET compiler directly. For example, the following C # program: Public class ctest {public ctest () {system.console.writeline ("Hello from ctest");}} can be compiled into a library element (DLL): CSC / T: library ctest. Cs You can see the contents of the components by running the "IL Anti-Disassembly" tool belled in .NET SDK. In addition, you can also compile your source code into modules, then use the component connector (Al.exe) to combine the module into a component. For the C # compiler, the / target: Module switch can specify a module instead of the component. 3.3 What is the difference between private components and shared components? Spatial allocation and visibility: Private components are usually used by an application, which is stored below this application or subdirectory below. Sharing elements are typically stored in a global component buffer, which is the storage of components maintained by .NET running. Sharing elements are usually the code base to be used in many applications, such as .NET Framework classes. Version Control: The runtime is only implemented on the shared component, not the private component. 3.4 How does the component find each other? By looking for a directory path. There are several factors that affect the path (such as AppDomain host, application profile, etc.), but for private components, search paths are usually the application's directory and their subdirectory. For shared components, search paths are usually the same as private components, plus shared component buffers. 3.5 How does the component version work? Each component is represented by a version number called a compatibility version. Similarly, references to components (from another component) include names and versions of the referenced components. The version number has four digital parts (for example, 5.5.2.33). Elements that are not the same in the first two parts are considered incompatible. If the top two are the same, the third part is different, and components are considered "possible." If only the fourth part is different, the component is considered compatible. However, this is just the default guidelines - is the scope of the version policy decision to apply these rules. Version Policy can be specified in the application configuration file. Remember: The version control is only for shared components, not the private component. 4. Application Domain 4.1 What is the application domain? AppDomain can be seen as a lightweight process. There can be multiple Appdomain in a Win32 process.
The main purpose of AppDomain is to separate applications and other applications. By using a separate address space, the Win32 process provides isolation. This method is effective, but the overhead is very large and the telescopic is not good. The .NET runtime is managed by controlling memory by controlling all memory used to apply AppDomain isolation -AppDomain, so the run library ensures that the APPDOMAIN cannot access each other's memory. 4.2 How to create AppDomain? Appdomains usually have host creation. The host includes Windows Shell, ASP and IE. When you run a .NET application from the command line, the host is the shell. Shell Creates a new AppDomain for each app. AppDomains can also be explicitly created by .NET applications. Here is an example to create a C # AppDomain, which creates an instance of the object, and then a method of performing object: using System; using System.Runtime.Remoting; public class CAppDomainInfo: MarshalByRefObject {public string GetAppDomainInfo () {return "AppDomain = " Appdomain.currentdomain.friendlyname;}
}
public class App {public static int Main () {AppDomain ad = AppDomain.CreateDomain ( "Andy's new domain", null, null); ObjectHandle oh = ad.CreateInstance ( "appdomaintest.exe", "CAppDomainInfo"); CAppDomainInfo adInfo = (Oh.unwrap ()); string info = adinfo.getAppdomainInfo (); console.writeline ("Appdomain Info:" info); Return 0;}} 4.3 I can write your own .NET host? can. Regarding how to do, see the source code of the DM.NET Moniker developed by Jason Whittington and Don Box (http://staff.develop.com/jasonw/clr/readme.htm). There is also a code example called Corhost in .NET SDK. 5. Garbage collection 5.1 What is garbage collection? Garbage collection is a system that runs the library components through it to manage objects of the object's survival cycle and their occupied stacks. For .NET, it is not a new concept - Java and many other languages / run libraries have been used for a while. 5.2 After the last reference to the object is canceled, it does not necessarily be destroyed immediately, right? Yes. The garbage collector does not provide destruction of objects and is a time guarantee for the memory. About the unclear objects in C #, Chris Sells has an interested clues: http://discuss.develop.com/archives/wa.exe? A2 = Ind0007 & l = DOT & P = R24819 2000 10 Month, Microsoft's Brian Harry posted a long analysis of this problem: http://discuss.develop.com/archives/wa.exe? A2 = ind0010a & l = DOTNET & P = R28572 Chris Sells responded to Brian posts Here: http://discuss.develop.com/archives/wa.exe? A2 = Ind0010c & l = DOTNET & P = R983 5.3 Why does not provide a sectified destructure? Because of the garbage collection algorithm. The .NET's garbage collector works through the list of all objects that are currently being used. All unrecognized objects during the scan can be destroyed and released. When the last reference to the object is canceled, this implementation of the algorithm makes the running library unable to get notifications - it can only discover when the next cleaning stack. Moreover, this algorithm performs garbage collection as little as possible to work most efficient. Typically, the consumption of the stack capacity triggers the collection process. 5.4 Is there a problem with the lack of determination in .NET? This does affect the design of the component. If your object requires expensive or shortage resources (such as locking the database), you need to provide some way to let the client tell the object after work. Microsoft recommends that you should provide a method called Dispose () for this purpose. However, this will cause problems in a distributed object - who calls the dispose () method in a distributed system? There is a need for some form of reference-counting mechanism or owner management mechanism to handle distributed objects - unfortunately, the run library is loved to this.
5.5 Determination of destructure affects the use of COM objects in managed code? Yes. When using COM objects from managed code, you actually rely on garbage collectors to eventually release your object. If your COM object has expensive resources and can only be released after the event is finally released, you may need to provide a new interface on your object to support explicit DISPOSE () methods. 5.6 I have heard that I should avoid using the Finalize method, then should I implement Finalize in my category? For the garbage collector, the object with the Finalize method is more work than the object that does not have this method. It also does not guarantee the order of Finalized, so there is a different view for accessing other objects from a Finalized method. Finally, it cannot guarantee that the finalized method will be called. So, never rely on it to clean up the resources of the object. Microsoft recommends the following way: public class ctest {public override void dispose () {... // cleanup activities gc.suppressFinalize (this);} protected override void finalize () {dispose ();}} Call Dispose (), the resource of the object is released, and the garbage collector is removed from the Finalize obligation by calling suppressFinalize (). In the most unfavorable case, that is, the client has forgotten to call Dispose (), there is a large chance to call Finalize () to finalize the resources of the object via the garbage collector. Due to the defects of the garbage collection algorithm, this looks like a fairly reasonable handling method. 5.7 Do I have a means of controlling garbage collection algorithms? A little. The System.gc class provides a pair of interesting methods. The first is a Collect method - it enforces the garbage collector to immediately collect all untruritable objects. The other is RequestFinalizeOnShutdown (), which tells the garbage collector to run the femalize () method for each object when the application is shut down. When the application is closed, the garbage collector generally selects a quick launch method rather than calling Finzlize (), so this method can manually force the library to negative a little responsibility. If you want to verify this is not just theoretical saying, it is a test program below: use system; class ctest {protected override void finalize () {console.writeline ("this is the finalizer.");}}
Class capplication {public static void main () {console.writeline ("this is main."); ctest test = new ctest (); // gc.requestfinalizeonseonShutdown ();}} Run this program, then remove GC.RequestFinalizeonShutdown () This line of comments marked and re-run, pay attention to what is different ... How do I know what the garbage collector is doing? Many of the .NET Runturing Base is output through the 'COM MEMORY' performance object. Use the Performance Monitor to view them. 6. Attribute 6.1 What is the property? There are minimal type .NET properties. The first category I call it Metadata property - it allows some data to be attached to the class or method. These data are numbered as part of the Metadata, and can be accessed by mapping like other Metadata classes. Another property of Metadata is [Serializable], which is attached to the class, indicating that the instance of the class can be serialized. [Serializable] Public class ctest {} Another type of attribute is context properties. The properties of the context type use and Metadata similar syntax, but they are actually different. The context type attribute provides an interpretation mechanism that can be pre-processed and / or subsequently processed by this mechanism. If you know the General Brown's General Brown, you might be familiar with this idea. 6.2 Can I create my own metadata properties? Yes it is. Simply export a class from System.attribute and tag it as an AttributeUSAGE property. For example: [AttributeUsage (AttributeTargets.Class)] public class InspiredByAttribute: System.Attribute {public string InspiredBy; public InspiredByAttribute (string inspiredBy) {InspiredBy = inspiredBy;}}
[InspiredBy ( "Andy Mc's brilliant .NET FAQ")] class CTest {} class CApp {public static void Main () {object [] atts = typeof (CTest) .GetCustomAttributes (); foreach (object att in atts) if ( ATT is inspiredByattribute) Console.Writeline ("Class Ctest Was Inspired By {0}", _ ((InspiredByattribute);}} 6.3 Can I create my own context property? Yes it is. Take a look at the TRATER DRAYTON at the Don Box at http://www.develop.com/dbox/dotnet/threshold (called Callthreshold) and http://www.razorsoft.net/ TRATER DRAYTON TRACEHOK.NET