Marshaling - what is it and why do we need it?

What is sorting and why do we need it?

Itโ€™s hard for me to believe that I canโ€™t send int over the explorer from C # to C and must process it. Why doesn't C # just send 32 bits with a start and end signal, telling the C code that it got an int ?

If there are good tutorials or sites about why we need to sort and how to use it, that would be great.

+82
c # marshalling managed unmanaged
Feb 10 '10 at 22:23
source share
6 answers

Because different languages โ€‹โ€‹and environments have different calling conventions, different layout conventions, different primitive sizes (see char in C # and char in C), different conventions for creating / destroying objects, and different design guidelines. You need a way to pull material from managed land into a place where unmanaged land can see and understand it, and vice versa. This is what you need for sorting.

+67
Feb 10 2018-10-10T00
source share

.NET code (C #, VB) is called "managed" because it is "managed" using the common language runtime (CLR)

If you write code in C or C ++ or assembler, they are all called "unmanaged" because the CLR is not involved. You are responsible for all allocation / allocation of memory.

Marshaling is the process between managed code and unmanaged code; This is one of the most important services offered by the CLR .

+15
Apr 7 '16 at 15:44
source share

Marshalling an int ideally is what you said: copying memory from a managed CLR stack to a place where C code can see it. Massing strings, objects, arrays, and other types are difficult things.

But the P / Invoke interaction layer takes care of almost all of these things for you.

+10
Feb 10 2018-10-10
source share

As Vinko says in the comments, you can pass primitive types without any special sorting. They are called "blittable" types and include types such as byte, short, int, long, etc. And their unsigned counterparts.

This page contains a list of Blittable and Non-Blittable types .

+6
Feb 10 '10 at 22:38
source share

Marshalling is a "medium" due to the lack of a better word or gateway, for communicating with unmanaged world data types and vice versa, using pinvoke and ensuring data is returned in safe mode.

+4
Feb 10 '10 at 22:37
source share

Marshalling passes the function signature to another process that resides on another machine, and this is usually done by converting structured data into a special format that can be transferred to other processor systems (serialization / deserialization)

+1
Jan 05 '19 at 19:11
source share



All Articles