When running our assembly which PInvokes to an unmanaged dll, I am getting
the exception System.Runtime.InteropServices.MarshalDirectiveException : Can
not marshal parameter #1: Invalid managed/unmanaged type combination
(Int/UInt must be paired with I or U). This exception only occurs when
compiling in release mode. The PInvoke call resembles this:
[DllImport("UnmanagedLibrary", EntryPoint = "FunctionName1")]
internal static extern ErrorCode FunctionName1(IntPtr pHandle,
PropertyTagEnum prop, uint uval);
The header in the Unmanaged Library is:
XXX_API ErrorCode FunctionName1(DecompHandle handle, PropertyTag prop,
unsigned long ulValue);
I tried changing the IntPtr pHandle to int, and receive a similar exception:
Can not marshal parameter #1: Invalid managed/unmanaged type combination
(Int32/UInt32 must be paired with I4 or U4). I tried adding a
[MarshalAs(UnmanagedType.I4)] but it still throws the exception.
Any ideas?
-Bill
Bill - 20 Oct 2004 19:53 GMT
Come to find out this was a strange problem with the obfuscator we use.
-Bill
> When running our assembly which PInvokes to an unmanaged dll, I am getting
> the exception System.Runtime.InteropServices.MarshalDirectiveException : Can
[quoted text clipped - 18 lines]
>
> -Bill