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 / April 2004

Tip: Looking for answers? Try searching our database.

P/Invoke & CallBack functions

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Maxim Kazitov - 31 Mar 2004 21:54 GMT
Hi,

In my project I call some C functions from C# code, and some times I should
use callback functions. Usually all works fine.

But in some cases I have following problem :

Error Message: Run Time Check Failure #0 The value of ESP was not properly
saved across a function call. This is usually a result of calling a function
declared with one calling convention with a function pointer declared with a
different calling convention

I implement call back through "delegate" statement. Is it possible to change
calling conversion for callback function in C# ?

Thanks
Max
Nicholas Paldino [.NET/C# MVP] - 31 Mar 2004 22:31 GMT
Maxim,

   I don't think that there is a way to do this.  The only way I can think
to do this would be to create a shim of some kind in unmanaged code, which
would store the function pointer passed to it (which uses a standard calling
convention, which is what I imagine .NET passes) and then expose a function
which can be passed to the function you want to call with the correct
calling convention.

   Hope this helps.

Signature

              - Nicholas Paldino [.NET/C# MVP]
              - mvp@spam.guard.caspershouse.com

> Hi,
>
[quoted text clipped - 13 lines]
> Thanks
> Max
JLarkin - 31 Mar 2004 23:21 GMT
H
Have a look at the CallingConvention enumeration in the msdn docs.  This may be what you are looking for.
Maxim Kazitov - 01 Apr 2004 05:03 GMT
No this doesn't help.
But I found intersting article :
http://groups.google.com/groups?selm=ew6mLkV6BHA.1932%40tkmsftngp03

> Hi
> Have a look at the CallingConvention enumeration in the msdn docs.  This may be what you are looking for.

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.