[Mono-dev] p/invoke marshal struct to pointer

Gladish, Jacob Jacob.Gladish at sig.com
Fri Jul 17 11:44:50 EDT 2009


I'm using a third-party .NET wrapper around an unmanaged library that was intended for use on windows. I'm investigating whether this will work on work on Linux and am getting the following exception:

System.Runtime.InteropServices.MarshalDirectiveException: Can not marshal 'parameter #1': Pointers can not reference marshaled structures. Use byref instead.

I can confirm that the .NET wrapper is indeed trying to pass a pointer to a managed struct via p/invoke to an unmanaged function. I was curious if anyone could confirm to me whether that's a bug in the .NET wrapper or in the mono-runtime. This could runs fine on windows using the MS .NET runtime.

The mono runtime seems to have a specific check for this cause and throws the exception. I guess what's confusing is that if it's really not allowed, then why would the Microsoft runtime allow it?

Thanks
-jake


IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.


More information about the Mono-devel-list mailing list