Search code examples
c#asp.netvisual-studio-2008

What does "cannot be marshaled by the runtime marshaler" mean?


I am getting strange warnings out of Visual Studio 2008 when compiling a C# ASP.NET application. Could anyone point me to an explanation (in words of few syllables, if possible) of what this warning means?

At least one of the arguments for 'IasHelper.Process' cannot be marshaled by the runtime marshaler. Such arguments will therefore be passed as a pointer and may require unsafe code to manipulate.


Solution

  • The Marshal class is responsible to convert unmanaged code/classes to managed classes and vice versa. See the msdn documentation of the Marshal Class.

    If you include some interop assembly to access COM object or such it may happen that the Marshal(l)er cannot take care of the operation. Thus you have quasi-unmanaged parts running in your program which in turn can cause nasty things like buffers overruns and such. You thereby leave the safe, cozy world of managed code and enter the drafty, dangerous realm of C/C++ and their dreaded brethren. :-)