Marshaling is the act of taking data from the environment you are in andexporting it to another environment. In the context of .NET, marhsalingrefers to moving data outside of the app-domain you are in, somewhere else.
When you work with unmanaged code, you are marshaling data from yourmanaged app-domain to the unmanaged realm. Also, when transferring databetween app-domains (to another application, on the same or anothermachine), you are also marshaling data from your app-domain, to anotherapp-domain.
Marshaling is serializingor transforming types over the wire or some boundary. COM had marshalingwhen you went out of one apartment into a non-compatible apartment or acrossthe wire to another machine. When dealing with COM Interop, .NET usesInterop Marshaling between COM data types and .NET CLR types.
Unmanaged code is simply all code pre .NET. It is all code NOT compiled tooperate under .NET's runtime, the CLR. Unmanaged code is code compiled andlinked natively and has no knowledge of the CLR. Unmanaged code can benative C++ with pointers, or C, or VB 6, or Delphi, etc. It is everythingnot managed by the CLR. In the CLR, code is compiled into IL + metadata intoassemblies and then those assemblies are JITed into assembly languageinstructions while called. It is the metadata throughout that allows managedcode to be managed, managed by the CLR.
From the perspective of a .NET developer, managed code does in fact equal..NET code, and unmanaged code is all code that does not run under the CLR.However, Java bytecode is often referred to as "managed code" as well. Bythis more generic definition, managed code is any code that is run in amanaged environment that controls security access and access to resources.That managed environment might be .NET's Common Language Runtime, Java'sbytecode interpreter, or something else. It is not enough for the code torequire a supporting runtime; VB6 or FoxPro executables, for example, arenot "managed" in this sense. A support library full of routines ispassively called by such code; but unlike a suport library, a mangedenvironment may refuse application an request if it violates securityprotection levels or accesses forbidden resources. In order to be able todetermine whether or not to honor requests, the application code must beself-describing; hence the other requirement to call an executionenvironment "managed."
No comments:
Post a Comment