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 / Languages / Managed C++ / November 2006

Tip: Looking for answers? Try searching our database.

Why can't Marshal::GetDelegateForFunctionPointer() work on C++?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rory Plaire - 20 Oct 2006 21:46 GMT
After searching and experimentation, I found the note in the remarks section
of the MSDN doc on Marshal::GetDelegateForFunctionPointer
(http://msdn2.microsoft.com/en-us/library/system.runtime.interopservices.marshal.
getdelegateforfunctionpointer.aspx
) -

   You cannot use this method with function pointers obtained through C++...

Why not?
SvenC - 21 Oct 2006 16:21 GMT
Hi,

> After searching and experimentation, I found the note in the remarks
> section
[quoted text clipped - 6 lines]
>
> Why not?

I guess the documentation is talking about class function pointers. Native
function pointers and class function pointers are of different size and need
different code to be called so they are not compatible.

--
SvenC
Ben Voigt - 07 Nov 2006 20:46 GMT
> After searching and experimentation, I found the note in the remarks
> section
[quoted text clipped - 6 lines]
>
> Why not?

Calling convention, I would guess.  That method probably assumes stdcall,
while C++ uses thiscall except for variable length argument lists which use
cdecl.

It also mentions that you can't use a function pointer to a managed method,
and if you compile your C++ code with /clr then chances are your C++
functions are MSIL (managed).

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.