1. managed code2. unmanaged code3
C ++4. SummaryEdit the returned directoryCode that is managed by the public Language Runtime Library environment (instead of directly executed by the operating system. Hosted code applications can obtain the Common Language Runtime library service, such as automatic garbage collection, Runtime Library type check, and security support. These services help provide unified managed code application behavior independent of platform and language.
Edit the returned directoryCode that is directly executed by the operating system outside the public Language Runtime Library environment. The unmanaged code must provide its own services such as garbage collection,
type check, and security support. Unlike the hosted code, the latter obtains these services from the public Language Runtime Library.
Edit the returned directoryTo answer this question, you must first understand what is managed ).
is. net is a new programming concept integrated with the general language runtime (CLR). Therefore, we can regard "hosting" as ".. net ". So what is "general language runtime "? The general language runtime is the execution lead of. NET Framework applications. It provides many services, including code management (load and execution), type security verification, metadata (advanced type information) Access, memory management for management objects, and code management, interaction and operability of COM objects and pre-generated DLLs (non-managed code and data), jeopardy guest hosts and support for developers' services.
That is to say, the use of managed C ++ means that our code can be managed by Clr and can develop new features such as automatic garbage collection and inter-program access.. NET Framework application. The C ++ application triggered by the concept of hosting consists of three parts: hosting code, hosting data,
(1) managed code: the. NET environment provides many core runtime services, such as exception handling and security policies. To be able to use these services, you must provide some information code (metadata) to the runtime environment, which is the managed code. All C # and VB. net, JScript. net is hosted by default, but visual c ++ is not hosted by default. You must use the command line option (/CLR) in the compiler to generate managed code. (2) managed data: managed data is closely related to managed code. Managed Data is the data allocated and released by the garbage collector running in the public language. By default, hosta C #, visual
Basic and JScript. NET data are hosted data. However, by using special keywords, C # data can be labeled as unmanaged data. Visual c ++ data is not hosted by default, even when the/CLR switch is used.
(3) hosting: Although visual c ++ data is not hosted by default, you can use the "_ GC" keyword to mark the class as a Managed class. As shown in the name, it indicates that the memory of the class instance is managed by the garbage collector. In addition, a Managed class can also be. net Framework members, which can bring about the benefit that it can correctly perform operations with classes written in other languages, for example, hosted C ++ classes can be inherited from visual basic classes. But there are also some restrictions, such as hosting classes can only inherit from one base class. It should be noted that in a hosted C ++ application, hostos community college hostos community college both managed classes and unmanaged classes can be used. The unmanaged class here is not a standard C ++ class, but a class hosting the _ nogc keyword in the C ++ language.
Edit the returned directorySummary managed code is the code written for the service of the public Language Runtime Library (see "What is a public Language Runtime Library ?"). To target these services, the Code must provide the Runtime library with the lowest level of information (metadata ). By default, all C #, Visual Basic. net, and JScript. Net code are hosted. By default, Visual Studio. net c ++ code is not hosted, but the compiler can generate managed code by specifying the command line switch (/CLR. Managed Data is closely related to managed code (Data allocated and released by the garbage collector of the Common Language Runtime ). By default, C #, visual
Basic and JScript. NET data are hosted. However, you can use special keywords to mark C # data as unmanaged. By default, Visual Studio. net C ++ data is not hosted (even when/CLR is used), but when using C ++ to manage extensions, you can mark the class as hosted by using the _ GC keyword. As the name implies, this means that the memory used for the class instance is hosted by the garbage collector. In addition, the class becomes a fully-involved Member of the. NET Framework Community, which brings both benefits and restrictions. One benefit is the correct interoperability with classes written in other languages (for example, a hosted C ++ class can
Visual Basic class inheritance ). One restriction is that the Managed class can only inherit from the base class.