[Mono-dev] Invoking unmanaged code without marshaling
mzabani at gmail.com
Sun Dec 2 20:11:53 UTC 2012
Hi everyone, I've been trying to find a way to invoke unmanaged code
without any marshaling, i.e. by making my unmanaged functions receive
Mono's objects (or their addresses).
I've read the Embedding Mono page (a very good one at that) and found that
if I embed Mono in my application, I could call mono_add_internal_call on
my unmanaged functions and mark my C# methods with
[MethodImplAttribute(MethodImplOptions.InternalCall)]; there is a catch in
my case, however.
I am not trying to embed Mono in my application, I'm trying to avoid
marshaling from my "standard" .NET app to my C API calls since my C
functions deal with large byte arrays all the time, and this implies a
significant overhead in allocating and copying them. I would much rather
try pinning the arrays and accessing the underlying C-like array directly
in some cases (is this possible and is this in Mono's public API?). For
this reason, I can only run mono_add_internal_call after my managed code
has already executed, and apparently because of this I'm getting
Unhandled Exception: System.MissingMethodException: Cannot find the
Is there anyway to achieve what I want?
This is my first time with Mono's internals and I'm only beginning with
Interop, so please excuse any stupidities I may be doing.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Mono-devel-list