Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 424
Brian Hooper Avatar asked Oct 07 '11 08:10

Brian Hooper


2 Answers

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. :-)

like image 101
Christoph Grimmer-Dietrich Avatar answered Nov 11 '22 01:11

Christoph Grimmer-Dietrich


Sounds like you're referencing an ActiveX object and its giving the tlbimp.exe a tough time marshaling the arguments of some of the methods and structure members between COM and .NET.

this maybe happening during clean builds as that's the only time tlbimp has to run. try to do a normal build where you didn't not clean first.

like image 23
SShebly Avatar answered Nov 10 '22 23:11

SShebly