I've an interface with the following method:
void Show(
[In, MarshalAs(UnmanagedType.I4)]
int fShow);
void UIActivate(
[In, MarshalAs(UnmanagedType.I4)]
int fUIActivate);
When I call these methods, using this cocde in C#:
interopDocumentView.Show(-1);
interopDocumentView.UIActivate(-1);
I get the following error:
"Cannot marshal parameter #1: Invalid managed/unmanaged type
combination, (Int32/UInt32 must be combined with I4 or U4"
This is strange, as I marshal explicitly to I4 and -1 is obviously
Int32, as the error message stated.
Is there any thing I've forgotten in my interface definition??
Thanks for your thoughts,
Joerg
RichM - 15 Jul 2004 21:47 GMT
Ive noticed that dotnet is really cumbersome when it comes to signed/unsigned integers. I always have trouble with interop when my operation moves a 1 into the sign bit of an int. For example, you can't assign an int to hex value 0xffffffff, even though you meant (-1) and it is perfectly mathematically correct to do so. So if you need to load a DWORD with a high and low word for a Platform SDK call, you really have to jump through some hoops. The same annoyance is caused by an int that is composed of bitflags.
> I've an interface with the following method:
>
[quoted text clipped - 24 lines]
>
> Joerg