编组站 - 它是什么,为什么我们需要它? [英] Marshalling – what is it and why do we need it?
问题描述
什么是编组,为什么我们需要它?
What is marshalling and why do we need it?
我觉得很难相信,我不能发送 INT
在从C#到C线,并有马歇尔它。为什么不能C#只是把32位超过了起始和终止的信号,告诉它已经收到了 INT
?
I find it hard to believe that I cannot send an int
over the wire from C# to C and have to marshall it. Why can't C# just send the 32 bits over with a starting and terminating signal, telling C code that it has received an int
?
<子>如果有,为什么我们需要编组,以及如何使用它的任何好的教程或网站,这将是巨大的。
推荐答案
由于不同的语言和环境有不同的调用约定,不同的布局惯例,不同大小的原语(参见字符
C#和字符
在C),不同的对象创建/销毁公约,不同的设计准则。你需要一种方式来获得的东西了管理土地进入的地方在那里未管理土地可以看到和理解它,反之亦然。这就是编组是。
Because different languages and environments have different calling conventions, different layout conventions, different sizes of primitives (cf. char
in C# and char
in C), different object creation/destruction conventions, and different design guidelines. You need a way to get the stuff out of managed land an into somewhere where unmanaged land can see and understand it and vice versa. That's what marshalling is for.
这篇关于编组站 - 它是什么,为什么我们需要它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!