What si Marshall Class

Hi

I from a while i still keep hearing about this... like "marshall class. does that, ..".. anyway what si this marshall class




Answer this question

What si Marshall Class

  • Dave Friedel

    Two simple quotes from the MSDN Documentation should answer you question:

    Provides a collection of methods for allocating unmanaged memory, copying unmanaged memory blocks, and converting managed to unmanaged types, as well as other miscellaneous methods used when interacting with unmanaged code.

    The static (Shared in Visual Basic) methods defined on the Marshal class are essential to working with unmanaged code. Most methods defined here are typically used by advanced developers building custom marshalers who need to provide a bridge between the managed and unmanaged programming models. For example, the StringToHGlobalAnsi method copies the ANSI characters from a specified string (in the managed heap) to a buffer in the unmanaged heap. It also allocates the target heap of the right size, as the following C# code shows:

    String s = "Hello";
      IntPtr p = Marshal.StringToHGlobalAnsi(s);

    The common language runtime provides specific marshaling capabilities. For details on marshaling behavior, see Interop Marshaling.

    The Marshal class comprises many diverse members. The following table assigns each member to the category that best describes its usage.



  • PRaevsky

    thanks!!


  • Plasmatic

    I think the most command usage of this class is with COM interoption development.

    A good article to read about it can be found on C# Help: Call Unmanaged Code Part 2 - Marshal Class.



  • Comet

    You are welcome!

    Try to avoid the using of marshalling and try to use managed classes. But in some situations you can't get around it.



  • targ

    Thanks.. but didnt actualy get it maybe because. its for "advanced developers building custom marshalers"

    PJ. van de Sande can you say in what should you use this class or when ypu need this class



  • What si Marshall Class