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++ / September 2003

Tip: Looking for answers? Try searching our database.

How to pass delegate to unmanaged function from MC++ ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alexander Arlievsky - 22 Sep 2003 21:58 GMT
Hi,
I have mixed mode dll, which contains files with managed objects written in
MC++, and files with regular "C" functions.
One of those functions receives function pointer as parameter. I want to
pass to it delegate to managed object method.
I know how to do it from C# - DllImport etc. I suspect I can declare "stub"
method using those attributes, so it will actually reference "C" method, and
call this stub, letting marshaler to do the job. This will require to make
this "C" function exported. Is there another way to do it without simulating
C# way ?

Signature

==============================
Alexander Arlievsky
sasha@mprest.com
"The best tools for debugging are brains"
==============================

Igal Ioffe - 26 Sep 2003 21:37 GMT
Hi Alex,

As far as I know - the official answer is no.

The method "similar" to c# method (that you don't want to use) can be
viewed here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cp
concallbacksample.asp


BUT, though bit controversal, there is a method, in such you
can switch between clr calling convention and other calling
conventions: http://www.codeproject.com/managedcpp/cbwijw.asp

Don't foget to keep the delegate reference alive ...

Also if it helps you, you can use the "#pragma managed/unmanaged"
directive
to break code into managed/unmanaged parts.

Igal.

> Hi,
> I have mixed mode dll, which contains files with managed objects written in
[quoted text clipped - 6 lines]
> this "C" function exported. Is there another way to do it without simulating
> C# way ?

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.