Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / July 2004

Tip: Looking for answers? Try searching our database.

Marshalling riddle

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Joerg Krause - 14 Jul 2004 18:28 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.